1. What is a digital signature?
A digital signature is a sign of your program as your own, and when someone sees the signature, they know it's relevant to you .
2. Why digital signatures? The simplest and most straightforward answer: system requirements. Android requires every Android app to be digitally signed to install into the system, meaning that if an Android app is not digitally signed, there is no way to install it! Android uses digital signatures to identify the author of an application and establish a trust relationship between applications, not to determine which applications the end user can install. This digital signature is done by the author of the application and does not require an authoritative digital certificate signing Authority authentication, which is only used to make the application package self-certified.
3. What is the mechanism of digital certificates? Android uses a Java digital certificate-related mechanism to give the APK a digital certificate, to understand the digital certificate of Android, you need to first understand the following digital certificate concepts and Java digital certificate mechanism.
4. Benefits of using the same digital certificate for the program
(1) facilitates program upgradewhen the new program and the old version of the program's digital certificate, the Android system will consider the two programs are different versions of the same program. If the new program and the old version of the digital certificate is not the same, then the Android system think they are different programs, and create a conflict, will require the newly-created program to change the package name.
(2) facilitates the modular design and development of the program. Android allows programs with the same digital signature to run in one process, and the Android program treats them as the same program. So developers can develop their own programs into modules, and users only need to download the appropriate modules when needed.
(3) data and code can be shared across multiple programs through permissions (permission). Android provides a digital certificate-based permission-granting mechanism that allows applications to share overviews or data with other programs to those that have the same digital credentials as themselves. If the ProtectionLevel of a permission (permission) is signature, this permission can only be granted to programs that have the same digital certificate as the package in which the permission resides.
5.
When signing, you need to consider the validity period of the digital certificate :
(1) The validity period of the digital certificate should include the program's expected life cycle, once the digital certificate expires, the program that holds the digital certificate will not be upgraded properly.
(2) If multiple programs use the same digital certificate, the validity period of the digital certificate will include the expected lifetime of all programs.
(3) Android market enforces that all application digital certificates remain valid until October 22, 2033.
6. Key points of the digital certificate:
Android digital certificates include the following points:
(1) All applications must have a digital certificate , Android does not install an application that does not have a digital certificate
(2) the digital certificate used by the Android package can be self-signed , there is no need for an authoritative digital certificate Authority signature authentication
(3) if you want to formally publish an Android, You must use a digital certificate generated by a suitable private key to sign the program instead of using the ADT plugin or the debug certificate generated by the Ant tool to publish.
(4) digital certificates are valid . Android only checks the validity of the certificate when the application is installed. If the program is already installed on the system, it does not affect the normal functionality of the program, even if the certificate expires.
(5) Android uses standard Java tools Keytool andjarsigner
6) Use the
zipalign optimization program.
two modes of digital signature
we all know that Android does not install an APK program that runs without a digital signature, whether it is on the emulator or on the actual physical device. So we have a question, why do I not perform any signature operations during the daily development process, and the program will run on the emulator and the real machine? Now let's talk about
two modes of the APK program: Debug Mode (debugmode) and release mode
1. Debug mode: in debug mode, ADT automatically uses the debug key to sign the application, so we can run the program directly.
Debug Key: a file named Debug.keystore
storage location: C:\Users\Xiaopeng\.android\debug.keystore Xiaopeng corresponding to the user name replaced by their operating system
Two risks: The debug signed application has such two risks:
1) The debug signature app cannot be sold on Android Market, it will force you to use your own signature;
2) Debug.keystore on different machines may not be the same, it means that if you change the machine for the APK version upgrade, then the above program will not cover the installation of the problem. do not belittle this problem, if you develop the program only you use, of course, no matter, uninstall and install it. But if your software has a lot of customer use, this is a big problem, the equivalent of software does not have upgrade features!
so be sure to have their own digital certificate to sign;
2. Release mode:
when you want to publish a program, developers need to use their own digital certificate to sign the APK package
two ways to sign the APK with your own digital certificate:
(1) Sign the APK with a DOS command.
(2) Signing with ADT Export Wizardreprint Please indicate source: Bi Xiaobong - http://blog.csdn.net/wirelessqa
"Turn" the role and meaning of the digital signature of Android APK