code: private void writeSignatureBlock(Signature signature, X509Certificate publicKey,
              PrivateKey privateKey)
              throws IOException, GeneralSecurityException {
          SignerInfo signerInfo = new SignerInfo(
                  new X500Name(publicKey.getIssuerX500Principal().getName()),
                  publicKey.getSerialNumber(),
                  AlgorithmId.get(DIGEST_ALGORITHM),
                  AlgorithmId.get(privateKey.getAlgorithm()),
                  signature.sign());
  
          PKCS7 pkcs7 = new PKCS7(
                  new AlgorithmId[] { AlgorithmId.get(DIGEST_ALGORITHM) },
                  new ContentInfo(ContentInfo.DATA_OID, null),
                  new X509Certificate[] { publicKey },
                  new SignerInfo[] { signerInfo });
  
          pkcs7.encodeSignedData(mOutputJar);
      }
docs: Write the certificate file with a digital signature.