开放签电子签章工具版,新增修改 CA 证书密码方法
由于本项目中生成的CA证书(测试)或者颁发的CA证书(正式)时,证书密码不支持修改。多个开源用户提议在使用中有修改证书密码的需要,现增加修改证书密码的测试类,欢迎各位用户测试使用。 package org.resrun; import org.apache.commons.io.FileUtils; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.security.KeyStore; import java.security.Security; public class UpdateCertPassword { public static void main(String[] args) throws Exception { byte [] pfx = FileUtils.readFileToByteArray(new File("C://example.pfx")); String oldPwd = "oldPwd"; String newPwd = "newPwd"; Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()); //加载证书 ByteArrayInputStream inputStream = new ByteArrayInputStream(pfx); KeyStore outputKeyStore = KeyStore.getInstance("PKCS12","BC"); outputKeyStore.load(inputStream,oldPwd.toCharArray()); //另存为证书 ByteArrayOutputStream out = new ByteArrayOutputStream(); outputKeyStore.store(out, newPwd.toCharArray()); byte [] newPfx = out.toByteArray(); FileUtils.writeByteArrayToFile(new File("C://new.pfx"),newPfx); } } 感谢各位开源用户的支持和参与,在使用过程中多多包容和提议~ 询问AI