android中全部运行在设备上的应用都必需要签名,这是系统提供的一种安全认证机制。
下面以问答形式来自我认识下,后面在根据部份内容来进一步研究: html
若是不签名呢?
直接安装到设备上,则也提示:
从上面能够有个很简易的认知,若是不签名或者签名不对,则不能安装在设备上。 java
若是应用androidmenifast.xml中加了android:sharedUserId="android.uid.system"时,要用平台签名,不然提示:
更多安装异常能够查找相关信息。 android
这里的platform.*即为平台签名的私钥和公钥,加密方式是非对称加密。
从上图能够看出有好几种的签名,4种具体表示可参考当前目录下的README.
安全
The following commands were used to generate the test key pairs: //制做key的脚本和相关信息 development/tools/make_key testkey '/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/emailAddress=android@android.com' development/tools/make_key platform '/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/emailAddress=android@android.com' development/tools/make_key shared '/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/emailAddress=android@android.com' development/tools/make_key media '/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/emailAddress=android@android.com' The following standard test keys are currently included: //testkey--当应用没有指定其余key时,源码默认以此key签名 testkey -- a generic key for packages that do not otherwise specify a key. //平台签名,系统级应用用此签名 platform -- a test key for packages that are part of the core platform. //当须要用到联系人的共享数据时,须要此签名 shared -- a test key for things that are shared in the home/contacts process. //对系统的media/download相关的应用,用此签名 media -- a test key for packages that are part of the media/download system. These test keys are used strictly in development, and should never be assumed to convey any sort of validity. When $BUILD_SECURE=true, the code should not honor these keys in any context. signing using the openssl commandline (for boot/system images) -------------------------------------------------------------- 1. convert pk8 format key to pem format % openssl pkcs8 -inform DER -nocrypt -in testkey.pk8 -out testkey.pem 2. create a signature using the pem format key % openssl dgst -binary -sha1 -sign testkey.pem FILE > FILE.sig extracting public keys for embedding ------------------------------------ it's a Java tool but it generates C code take a look at commands/recovery/Android.mk you'll see it running $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar
从shareed签名,能够联想到:
当A应用须要用到B应用的共享数据时,他们的android:sharedUserId="xxx"须要一致,签名也须要一致 app
loop android签名机制(2)——如何签名 oop
参考:http://www.cnblogs.com/heart-runner/archive/2012/01/30/2332020.html
ui
问题待补充...
参考: http://developer.android.com/tools/publishing/app-signing.html 加密