请选择至少一个在androidstudio2.3中使用的签名版本
现在,在Android Studio中生成签名APK时,它会显示两个选项(复选框),即1。V1 (Jar签名)和2。V2(完整的APK签名)作为签名版本在签名APK生成过程的最后一步。
那么,在新的Android Studio更新中,V1 (Jar签名)和V2(完整APK签名)之间有什么区别呢?
我应该使用哪种(或两者都使用)来签署apk来发布play store ?
此外,当我使用第二个选项时,我在安装APK时得到错误安装解析失败无证书。
我认为这是一个很好的答案。
APK签名方案v2验证
Locate the APK Signing Block and verify that:
Two size fields of APK Signing Block contain the same value.
ZIP Central Directory is immediately followed by ZIP End of Central Directory record.
ZIP End of Central Directory is not followed by more data.
Locate the first APK Signature Scheme v2 Block inside the APK Signing Block. If the v2 Block if present, proceed to step 3. Otherwise, fall back to verifying the APK using v1 scheme.
For each signer in the APK Signature Scheme v2 Block:
Choose the strongest supported signature algorithm ID from signatures. The strength ordering is up to each implementation/platform version.
Verify the corresponding signature from signatures against signed data using public key. (It is now safe to parse signed data.)
Verify that the ordered list of signature algorithm IDs in digests and signatures is identical. (This is to prevent signature stripping/addition.)
Compute the digest of APK contents using the same digest algorithm as the digest algorithm used by the signature algorithm.
Verify that the computed digest is identical to the corresponding digest from digests.
Verify that SubjectPublicKeyInfo of the first certificate of certificates is identical to public key.
Verification succeeds if at least one signer was found and step 3 succeeded for each found signer.
注意:如果步骤3或步骤4失败,APK不能使用v1方案进行验证。
jar签名的APK验证(v1方案)
JAR签名的APK是一个标准的签名JAR,它必须包含META-INF/MANIFEST中列出的条目。MF,其中所有条目必须由同一组签名者签名。其完整性验证如下:
Each signer is represented by a META-INF/<signer>.SF and META-INF/<signer>.(RSA|DSA|EC) JAR entry.
<signer>.(RSA|DSA|EC) is a PKCS #7 CMS ContentInfo with SignedData structure whose signature is verified over the <signer>.SF file.
<signer>.SF file contains a whole-file digest of the META-INF/MANIFEST.MF and digests of each section of META-INF/MANIFEST.MF. The whole-file digest of the MANIFEST.MF is verified. If that fails, the digest of each MANIFEST.MF section is verified instead.
META-INF/MANIFEST.MF contains, for each integrity-protected JAR entry, a correspondingly named section containing the digest of the entry’s uncompressed contents. All these digests are verified.
APK verification fails if the APK contains JAR entries which are not listed in the MANIFEST.MF and are not part of JAR signature.
The protection chain is thus <signer>.(RSA|DSA|EC) → <signer>.SF → MANIFEST.MF → contents of each integrity-protected JAR entry.
我认为这是一个很好的答案。
APK签名方案v2验证
Locate the APK Signing Block and verify that:
Two size fields of APK Signing Block contain the same value.
ZIP Central Directory is immediately followed by ZIP End of Central Directory record.
ZIP End of Central Directory is not followed by more data.
Locate the first APK Signature Scheme v2 Block inside the APK Signing Block. If the v2 Block if present, proceed to step 3. Otherwise, fall back to verifying the APK using v1 scheme.
For each signer in the APK Signature Scheme v2 Block:
Choose the strongest supported signature algorithm ID from signatures. The strength ordering is up to each implementation/platform version.
Verify the corresponding signature from signatures against signed data using public key. (It is now safe to parse signed data.)
Verify that the ordered list of signature algorithm IDs in digests and signatures is identical. (This is to prevent signature stripping/addition.)
Compute the digest of APK contents using the same digest algorithm as the digest algorithm used by the signature algorithm.
Verify that the computed digest is identical to the corresponding digest from digests.
Verify that SubjectPublicKeyInfo of the first certificate of certificates is identical to public key.
Verification succeeds if at least one signer was found and step 3 succeeded for each found signer.
注意:如果步骤3或步骤4失败,APK不能使用v1方案进行验证。
jar签名的APK验证(v1方案)
JAR签名的APK是一个标准的签名JAR,它必须包含META-INF/MANIFEST中列出的条目。MF,其中所有条目必须由同一组签名者签名。其完整性验证如下:
Each signer is represented by a META-INF/<signer>.SF and META-INF/<signer>.(RSA|DSA|EC) JAR entry.
<signer>.(RSA|DSA|EC) is a PKCS #7 CMS ContentInfo with SignedData structure whose signature is verified over the <signer>.SF file.
<signer>.SF file contains a whole-file digest of the META-INF/MANIFEST.MF and digests of each section of META-INF/MANIFEST.MF. The whole-file digest of the MANIFEST.MF is verified. If that fails, the digest of each MANIFEST.MF section is verified instead.
META-INF/MANIFEST.MF contains, for each integrity-protected JAR entry, a correspondingly named section containing the digest of the entry’s uncompressed contents. All these digests are verified.
APK verification fails if the APK contains JAR entries which are not listed in the MANIFEST.MF and are not part of JAR signature.
The protection chain is thus <signer>.(RSA|DSA|EC) → <signer>.SF → MANIFEST.MF → contents of each integrity-protected JAR entry.
我是否应该使用(或两者都使用)来签署apk来发布play store ?
答案是肯定的。
如https://source.android.com/security/apksigning/v2.html#验证
:
Android 7.0系统支持APK v2签名方案(v2方案)和JAR v1方案(v1方案)两种方式验证APK。旧的平台忽略v2签名,只验证v1签名。
我尝试用检查V2(完整的Apk签名)选项生成构建。然后,当我试图在7.0以下的设备中安装版本时,我无法在该设备中安装版本。
之后,我尝试通过检查版本复选框和生成发布版本来构建。然后能够安装构建。