Re: ftp ssl cert
On Aug 26, 2:30 pm, Lothar Kimmeringer <news200...@kimmeringer.de>
wrote:
If you use BouncyCastle:
PEMReader reader = new PEMReader(new FileInputStream("keycert.txt"));
PrivateKey key = (PrivateKey) reader.readObject();
X509Certificate cert = (X509Certificate) reader.readObject();
I get a:
org.bouncycastle.openssl.PEMException: problem parsing cert:
java.security.NoSuchProviderException: no such provider: BC
at org.bouncycastle.openssl.PEMReader.readCertificate(Unknown Source)
at org.bouncycastle.openssl.PEMReader.readObject(Unknown Source)
at com.kable.newsstand.KeyStoreTest.<init>(KeyStoreTest.java:15)
at com.kable.newsstand.KeyStoreTest.main(KeyStoreTest.java:26)
Caused by: java.security.NoSuchProviderException: no such provider: BC
at java.security.Security.getEngineClassName(Unknown Source)
at java.security.Security.getImpl(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at java.security.cert.CertificateFactory.getInstance(Unknown Source)
at the PrivateKey line. And of course I can't find any documentation
on this exception on BouncyCastle.org.
Code:
import org.bouncycastle.openssl.PEMReader;
import java.security.PrivateKey;
import javax.security.cert.X509Certificate;
import java.io.*;
public class KeyStoreTest {
public KeyStoreTest() {
try {
PEMReader reader = new PEMReader(new FileReader("keycert.txt"));
PrivateKey key = (PrivateKey) reader.readObject();
X509Certificate cert = (X509Certificate) reader.readObject();
reader.close();
reader = null;
}
catch (Exception ex) {
ex.printStackTrace();
}
}
}