JKS密钥存储格式的规范

emb*_*oss 9 java file-format keystore jks

我想知道是否存在Java中使用的JKS密钥库格式的官方规范?我想从/到PKCS#12编写一个转换器,但不是用Java编写,因此不幸的是,keytool或Java代码不是一个选项.

在十六进制编辑器中查看一个告诉我它可能不是ASN.1.在我开始深入研究OpenJDK之前,尝试对格式进行逆向工程,有没有人知道是否存在规范?到目前为止我找不到任何东西,任何帮助都会非常感激!

Kon*_*hov 13

我认为你应该从JDK 资源开始你的研究.那里有一些非常有用的评论.例如

/*
         * KEYSTORE FORMAT:
         *
         * Magic number (big-endian integer),
         * Version of this file format (big-endian integer),
         *
         * Count (big-endian integer),
         * followed by "count" instances of either:
         *
         *     {
         *      tag=1 (big-endian integer),
         *      alias (UTF string)
         *      timestamp
         *      encrypted private-key info according to PKCS #8
         *          (integer length followed by encoding)
         *      cert chain (integer count, then certs; for each cert,
         *          integer length followed by encoding)
         *     }
         *
         * or:
         *
         *     {
         *      tag=2 (big-endian integer)
         *      alias (UTF string)
         *      timestamp
         *      cert (integer length followed by encoding)
         *     }
         *
         * ended by a keyed SHA1 hash (bytes only) of
         *     { password + whitener + preceding body }
         */
Run Code Online (Sandbox Code Playgroud)