private static SubjectKeyIdentifier createSubjectKeyIdentifier(Key key) throws IOException {
        ByteArrayInputStream bIn = new ByteArrayInputStream(key.getEncoded());
        ASN1InputStream is = null;
        try {
            is = new ASN1InputStream(bIn);
            ASN1Sequence seq = (ASN1Sequence) is.readObject();
            SubjectPublicKeyInfo info = SubjectPublicKeyInfo.getInstance(seq);
            return new BcX509ExtensionUtils().createSubjectKeyIdentifier(info);
        } finally {
            NetBareUtils.closeQuietly(is);
        }
    }
Generate a root keystore by a given {@link JKS}.

@param jks A java keystore object.
@return A root {@link KeyStore}.
netbare-core/src/main/java/com/github/megatronking/netbare/ssl/CertificateGenerator.java