windows java.security.NoSuchProviderException:没有这样的提供者:SunMSCAPI
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4595129/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
java.security.NoSuchProviderException: no such provider: SunMSCAPI
提问by npocmaka
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:
我有几个程序SunMSCAPI
用于读取需要 SSL 证书的网页。我的代码在 Windows XP(32 位)下工作,但在我全新安装的 Windows 7(64 位)下不起作用。这是一段代码:
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.htmlbut again received this NoSuchProviderException
. My guess is that there is some configuration error but I'm not sure what it is.
我也尝试过以下示例http://muhammadhamed.blogspot.com/2010/04/accessing-ms-certificate-stores-in-java.html但再次收到了这个NoSuchProviderException
。我的猜测是存在一些配置错误,但我不确定它是什么。
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)
这是我的JVM信息: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.
此致。
回答by Powerlord
The J2SE Security pageonly says that the MS CryptoAPI (which SunMSCAPI uses) is only available under Java 6 on 32-bit Windows.
在J2SE安全页面只是说MS CryptoAPI的(这SunMSCAPI用途)仅在32位Windows的Java 6下可用。
Luckily, you can still install the 32-bit JVM on Win64.
幸运的是,您仍然可以在 Win64 上安装 32 位 JVM。