这是我的Javascript块:
<dependencies>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.52</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk15on</artifactId>
<version>1.52</version>
</dependency>
</dependencies>
在邮件调用之后的服务器端,我尝试以这种方式检索值:
package com.nguyen.eledra;
import java.io.FileReader;
import java.security.PrivateKey;
import java.security.Security;
import org.bouncycastle.asn1.pkcs.PrivateKeyInfo;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.openssl.PEMKeyPair;
import org.bouncycastle.openssl.PEMParser;
import org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter;
public class Main {
private static final String PEM_FILE = "/home/xxxxx/mykey.pem";
public static void main(String[] args) {
Security.addProvider(new BouncyCastleProvider());
FileReader fileReader;
try {
fileReader = new FileReader(PEM_FILE);
PEMParser parser = new PEMParser(fileReader);
PEMKeyPair kp = (PEMKeyPair) parser.readObject();
PrivateKeyInfo info = kp.getPrivateKeyInfo();
PrivateKey rdKey = new JcaPEMKeyConverter().setProvider("BC")
.getPrivateKey(info);
System.out.println(rdKey);
parser.close();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
但两个值均为空。
我在这里缺少什么? 提前谢谢!