gpt4 book ai didi

java.security.NoSuchProviderException : no such provider: SunMSCAPI

转载 作者:可可西里 更新时间:2023-11-01 10:09:13 28 4
gpt4 key购买 nike

我有几个程序使用 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();....

这是堆栈跟踪:

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

我也试过下面的例子 http://muhammadhamed.blogspot.com/2010/04/accessing-ms-certificate-stores-in-java.html但再次收到此 NoSuchProviderException。我的猜测是存在一些配置错误,但我不确定是什么。

这是我的 JVM 信息:
Java 版本“1.6.0_23”
Java(TM) SE 运行时环境(build 1.6.0_23-b05)
Java HotSpot(TM) 64 位服务器 VM(内部版本 19.0-b09,混合模式)

我希望有人能够帮助我 :-)

最好的问候。

最佳答案

J2SE Security page只说 MS CryptoAPI(SunMSCAPI 使用)仅在 32 位 Windows 的 Java 6 下可用。

幸运的是,您仍然可以在 Win64 上安装 32 位 JVM。

关于java.security.NoSuchProviderException : no such provider: SunMSCAPI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4595129/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com