Convert JKS to BKS using keytool

English 简体中文 繁体中文 ภาษาไทย Tiếng Việt
Summary

Converting a JKS keystore to the BouncyCastle BKS format with Java's keytool requires specific steps due to BKS not being a native Java SE keystore type. Developers must first download the BouncyCastle provider JAR. The keytool command then needs to include the -provider option, specifying org.bouncycastle.jce.provider.BouncyCastleProvider, and the -providerpath option, pointing to the downloaded BouncyCastle JAR file. This ensures the JVM can locate and utilize the third-party provider for the conversion process. This approach is generally applicable for converting between various keystore formats using external providers.

มีคำถามมากมาย(คำถามที่ 1, คำถามที่ 2) บน Stackoverflow เกี่ยวกับวิธีการแปลง JKS keystore เป็น BKS keystore(รูปแบบ keystore ที่จัดเตรียมโดย BouncyCastle) โดยใช้ Java keytool. 

เหตุผลที่การแปลงนี้มีคำถามมากมายก็คือ BKS ไม่ใช่รูปแบบ keystore ที่ Java SE รองรับ เป็นรูปแบบ keystore ของบุคคลที่สาม การแปลง JSK เป็น BKS ผู้ให้บริการ BKS จะต้อง ดาวน์โหลดก่อน และต้องเพิ่มตัวเลือกอีกสองสามตัวเลือกเมื่อเรียกใช้คำสั่ง keytool

คำสั่งทั่วไปในการแปลง JKS keystore เป็น BKS keystore ควรมีลักษณะดังนี้:

keytool -importkeystore -srckeystore testkeys -srcstoretype JKS -srcstorepass passphrase -destkeystore testkeys.bks -deststoretype BKS -deststorepass password -provider org.bouncycastle.jce.provider.BouncyCastleProvider -providerpath [PARENT_DIRECTORY_PATH]\bouncycastle\bcprov-jdk15on-152.jar

ตัวเลือกที่สำคัญสองตัวเลือกคือ -provider และ -providerpath. ตัวเลือก -provider บอก JVM ว่าบริการ BKS keystore ลงทะเบียนไว้ที่ใด และ -providerpath บอก JVM ว่าสามารถค้นหาผู้ให้บริการได้ที่ใด

ด้วยวิธีนี้ ไม่ควรมีปัญหาในการแปลง JKS keystore เป็น BKS keystore ตัวอย่างหนึ่งแสดงไว้ด้านล่าง

ก่อนการแปลง JKS keystore ประกอบด้วยรายการด้านล่าง:

หลังจากการแปลง BKS keystore ประกอบด้วยรายการด้านล่าง:

คำสั่งควรจะคล้ายกันหากคุณต้องการแปลงระหว่างรูปแบบ keystore ที่แตกต่างกัน

JAVA SECURITY JKS KEYTOOL BKS

  RELATED

  COMMENTS

3
Anonymous
Jun 2, 2017 at 6:37 am

Problem importing entry for alias capistore: java.security.KeyStoreException: java.io.IOException: Error initialising store of key store: java.security.InvalidKeyException: Illegal key size.

 

I keep getting the above error, any help would be appriciated 

Ke Pi
Jun 3, 2017 at 4:00 am

It may relate to the limited policy strength files located in jre\lib\security. Can you try to put the unlimited strength policy files there?

Anonymous
Feb 4, 2024 at 5:10 am

There are any ways to convert it using java methods? For example add dependency "implementation 'org.bouncycastle:bcprov-jdk18on:1.77'" and use it for transformation?