【发布时间】:2014-07-30 10:02:21
【问题描述】:
我有一个包含测试私钥的字符串变量,当输出密钥字符串时,它看起来像这样:
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,BD15DCECA635FDE0
[Encrypted-Key-Contents]
-----END RSA PRIVATE KEY-----
我已经检查了我的 ubuntu 系统,并且密钥有效并且可以工作。但是,当我尝试在其上运行 PEMParser 时,它只是挂起并且没有抛出异常。这是我为了解析它所做的:
System.out.println(myKey); // this outputs the key just fine.
Security.addProvider(new BouncyCastleProvider());
InputStream keyInput = new ByteArrayInputStream(myKey.getBytes());
InputStreamReader in2 = new InputStreamReader(keyInput);
PEMParser parserPrivateKey = new PEMParser(in2);
在创建 PEMParser 的行运行之前,一切似乎都运行良好。在此之后我的代码都没有运行,但是在使用我的应用程序(在 Mule 中)时我没有得到任何异常。
我在这里遗漏了什么吗?为什么从这段代码创建 PEMParser 实例会出现问题?
【问题讨论】:
标签: java encryption mule bouncycastle pem