android签名机制(3)——如何制作签名

一、制作android签名公钥/密钥

1.生成长度为2048位的RSA私钥

openssl genrsa -3 -out test.pem 2048

2.生成x509格式的公钥证书
openssl req -new -x509 -key test.pem -out test.x509.pem -days 10000

3.生成符合PKCS8标注的私钥文件
openssl pkcs8 -in test.pem -topk8 -outform DER -out test.pk8 -nocrypt


二、系统平台签名转eclipse签名

1.android 源码目录build\target\product\security 取platform.pk8 platform.x509.pem放到一个目录下

E:\sign\convert_keystore>ls

platform.pk8 platform.x509.pem

2.把pkcs8格式的私钥转换成pkcs12格式:

E:\sign\convert_keystore>openssl pkcs8 -in platform.pk8 -inform DER -outform PEM -out shared.priv.pem -nocrypt

E:\sign\convert_keystore>ls

shared.priv.pem platform.pk8 platform.x509.pem


3.把x509.pem公钥转换成pkcs12格式:

E:\sign\convert_keystore> openssl pkcs12 -export -in platform.x509.pem -inkey shared.priv.pem -out shared.pk12 -name androiddebugkey

Enter Export Password: (密码android)

Verifying - Enter Export Password:(密码android)


E:\sign\convert_keystore>ls

shared.priv.pem platform.pk8 platform.x509.pem shared.pk12


4.生成debug.keystore

E:\sign\convert_keystore>keytool -importkeystore -deststorepass android -destkeypass android -destkeystore debug.keystore -srckeystore shared.pk12 

-srcstoretype PKCS12 -srcstorepass android -alias androiddebugkey 

E:\sign\convert_keystore>ls

convert debug.keystore platform.pk8 platform.x509.pem shared.pk12 shared.priv.pem


5.eclipse 的Windows/Preferences/Android/Build中设置"Custom debug keystore"为刚才生成的keystore即可

后面接着分析签名过程:

android签名机制(4)——签名过程简析


你可能感兴趣的:(android,转换,签名,pkcs12,eclipse签名)