我正在尝试将 RSA pem 密钥(包含在字符串中)转换为字节 [],就像在给定 .pem 文件 FileInputStream 时此方法所做的那样:
我试过这个:
String pemKey = "-----BEGIN RSA PRIVATE KEY-----\r\n"
+ "{base64 encoded key part omitted}\r\n"
+ "{base64 encoded key part omitted}\r\n"
+ "{base64 encoded key part omitted}\r\n"
+ "-----END RSA PRIVATE KEY-----";
String base64 = pemKey
.replaceAll("\\s", "")
.replace("-----BEGINRSAPRIVATEKEY-----", "")
.replace("-----ENDRSAPRIVATEKEY-----", "");
return Base64.decode(base64.getBytes());
我希望结果与返回的结果相同,org.jets3t.service.security.EncryptionUtil.convertRsaPemToDer()
但在生成 CloudFront 流 URL 时它似乎不起作用。
知道我做错了什么吗?