Code signing
Android APKSigner
Create Java KeyStore
7 min
this section demonstrates how to use {{ch}} to create a private key and an android apk signing certificate for use with the java keystore finally, the keytool utility will be used to list the signing certificate, confirming that the private key and certificate were successfully imported into the keystore these steps ensure that you can use apksigner and the self certificate to sign an apk file in the next section perform the following tasks to create a ca for the android apk signing key pair create a new x 509 certificate container generate a new key pair for the android apk signing client create an approval group for apk signing add an issuance policy to the android apk signing client certificate create a certificate container perform the following steps to create a new x 509 certificate container open the {{ch}} web dashboard in a browser log in under dual control using the administrator identities select pki and ca on the left hand side > certificate management select \[ add ca ] at the bottom of the page or right click anywhere in the window and select add ca in the pop up menu, specify the following information for the certificate container name enter android apk signer host select none type select x 509 owner group in the drop down menu, select the role automatically created for the android apk signer service you deployed select \[ ok ] generate a key pair perform the following steps to generate a new key pair for the android apk signing client right click the x 509 certificate container you created and select add certificate > new certificate in the subject dn tab of the certificate creation wizard, select the classic preset in the drop down menu and specify apksignerdemo as the common name for the certificate in the basic info tab, you can leave the values set to the defaults in the v3 extensions tab, do not change the default value of none in the profile drop down list select \[ ok ] to finish creating the android apk signing client key pair create an approval group perform the following steps to create an approval group for pki signing on the pki and ca page, select pki signing approvals at the top select \[ add approval group ] at the bottom of the page or right click anywhere in the window and select add approval group specify android apk signer as the name for the approval group and select \[ ok ] right click the newly created approval group and select permission in the first drop down list, select the role automatically created for the android apk signer service you deployed, and select \[ add ] in the permission drop down menu for the android apk signer role, select the use permission select \[ save ] add an issuance policy perform the following steps to add an issuance policy to the android apk signing client certificate on the pki and ca page, select certificate management at the top expand the android apk signer certificate container view by selecting the plus (+) icon next to it right click the apksignerdemo certificate and select issuance policy > add in the basic info tab, configure the following settings approvals select 0 the zero approval policy requires anonymous signing, which will be enabled in a future step allowed hashes select sha1 and sha 256 in the x 509 tab, set the default approval group to android apk signer in the object signing tab, select the allow object signing checkbox select \[ ok ] to apply the issuance policy to the apksignerdemo client certificate right click the apksignerdemo certificate and select change security usage in the security usage drop down menu, select anonymous signing select \[ ok ] to apply the change verifying the private key and certificate in the java keystore the keytool application is included in the jdk installation, so you can run the keytool command in this section with no additional configuration in a terminal of the device that will be signing apks, run the following command keytool list keystore none storetype pkcs11 providerclass sun security pkcs11 sunpkcs11 providername sunpkcs11 futurex when prompted for the keystore password, enter the identity password configured inside the \<crypto opr pass> tag in the fxpkcs11 cfg file if the command succeeds, you should see an output similar to the following keystore type pkcs11 keystore provider sunpkcs11 futurex your keystore contains 1 entry android apk signer\ apksignerdemo\ c, privatekeyentry, certificate fingerprint (sha 256) 31 25 8e 83\ d8\ d9\ da\ a3 03 33\ e8 1b 27 29\ b8\ e4\ b4 24 18 1e 17 7c\ a0\ ce 6a 3d\ c0\ e3\ d1 97 71 0d important take note of the title (in this example, android apk signer\ apksignerdemo\ c ) of the entry as that will be needed for the signing command in the next section