Reputation: 57262
I have several programs that use SunMSCAPI
to read web pages that require an SSL certificate. My code works under Windows XP (32 bit) but does not work under my fresh installation of Windows 7 (64 bit). Here is the piece of code:
System.setProperty("javax.net.ssl.keyStoreProvider", "SunMSCAPI");
System.setProperty("javax.net.ssl.keyStoreType", "WINDOWS-MY");
System.setProperty("javax.net.ssl.trustStoreProvider", "SunMSCAPI");
System.setProperty("javax.net.ssl.trustStoreType", "WINDOWS-ROOT");
System.setProperty("proxyHost", "proxy");
System.setProperty("proxyPort", "8080");
URL url = new URL(TEST_URL);
try {
HttpsURLConnection httpsCon = (HttpsURLConnection) url.openConnection();....
And here is the stack trace:
Caused by: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: com.sun.net.ssl.internal.ssl.DefaultSSLContextImpl)
at java.security.Provider$Service.newInstance(Unknown Source)
at sun.security.jca.GetInstance.getInstance(Unknown Source)
at sun.security.jca.GetInstance.getInstance(Unknown Source)
at javax.net.ssl.SSLContext.getInstance(Unknown Source)
at javax.net.ssl.SSLContext.getDefault(Unknown Source)
at javax.net.ssl.SSLSocketFactory.getDefault(Unknown Source)
at javax.net.ssl.HttpsURLConnection.getDefaultSSLSocketFactory(Unknown Source)
at javax.net.ssl.HttpsURLConnection.<init>(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.<init>(Unknown Source)
at sun.net.www.protocol.https.Handler.openConnection(Unknown Source)
at sun.net.www.protocol.https.Handler.openConnection(Unknown Source)
at java.net.URL.openConnection(Unknown Source)
at GetData2.SetVallues(GetData2.java:56) *// HttpsURLConnection httpsCon = (HttpsURLConnection) url.openConnection();*
... 2 more
Caused by: java.security.NoSuchProviderException: no such provider: SunMSCAPI
at sun.security.jca.GetInstance.getService(Unknown Source)
at sun.security.jca.GetInstance.getInstance(Unknown Source)
at java.security.Security.getImpl(Unknown Source)
at java.security.KeyStore.getInstance(Unknown Source)
at com.sun.net.ssl.internal.ssl.DefaultSSLContextImpl.getDefaultKeyManager(Unknown Source)
at com.sun.net.ssl.internal.ssl.DefaultSSLContextImpl.<init>(Unknown Source)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
... 15 more
I've tried also following example http://muhammadhamed.blogspot.com/2010/04/accessing-ms-certificate-stores-in-java.html but again received this NoSuchProviderException
. My guess is that there is some configuration error but I'm not sure what it is.
Here is my JVM information:
java version "1.6.0_23"
Java(TM) SE Runtime Environment (build 1.6.0_23-b05)
Java HotSpot(TM) 64-Bit Server VM (build 19.0-b09, mixed mode)
I hope somebody will be able to help me :-)
Best regards.
Upvotes: 2
Views: 8333
Reputation: 88796
The J2SE Security page only says that the MS CryptoAPI (which SunMSCAPI uses) is only available under Java 6 on 32-bit Windows.
Luckily, you can still install the 32-bit JVM on Win64.
Upvotes: 3