jQuery in Action, 3rd edition
The moose likes Security and the fly likes Algorithm X509 not available Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Security
Bookmark "Algorithm X509 not available" Watch "Algorithm X509 not available" New topic

Algorithm X509 not available

Ashutosh Shinde
Ranch Hand

Joined: Jun 07, 2001
Posts: 42
I am trying to use a pfx file for client certification
The code is as below -
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
FileInputStream fis = new FileInputStream("D:\\CertificationServer\\merchantopus.pfx");
KeyStore ks2 = KeyStore.getInstance("PKCS12", "BC");
KeyManagerFactory kmf = kmf = KeyManagerFactory.getInstance("X509");
The following lines give the error -
java.security.NoSuchAlgorithmException: Algorithm X509 not available
at com.sun.net.ssl.b.a([DashoPro-V1.2-120198])
at com.sun.net.ssl.KeyManagerFactory.getInstance([DashoPro-V1.2-120198])
at BCTest.test(BCTest.java:28)
at BCTest.main(BCTest.java:12)
Could someone provide pointers to resolve the error?
Lewin Chan
Ranch Hand

Joined: Oct 10, 2001
Posts: 214
The error is actually quite meaningful - X509 isn't available as an algorithm. What this means is that none of the installed providers has an implementation of "X509" that can be used by KeyManagerFactory.
For instance, listing the available algorithms could be done like this :-

You will probably find that X509 is not listed.
I'm haven't used the bouncy castle provider, however, there should be a algorightm that is supplied with the JDK (at least it was with jdk1.3) called SunX509 which can be used when invoking KeyManagerFactory.getInstance()

I have no java certifications. This makes me a bad programmer. Ignore my post.
I agree. Here's the link: http://aspose.com/file-tools
subject: Algorithm X509 not available
It's not a secret anymore!