我在执行下面的代码时遇到异常
public static void main( String[] args )
{
System.getProperties().put("https.proxyHost","www-proxy.idc.myproxy.com");
System.getProperties().put("https.proxyPort", "80");
System.setProperty( "javax.net.ssl.keyStore","D:\\motorweb.p12"); // The path to the .p12 file
System.setProperty( "javax.net.ssl.keyStorePassword","******"); // The password of the p12 file
System.setProperty( "javax.net.ssl.keyStoreType", "PKCS12" ); // Default is JKS, we're using PKCS12
try {
URL url = new URL( "https://*******************?reference=43888db2" );
// Parse the XML into a DOM tree
Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse( url.openStream() );
// Serialize it out to the console
TransformerFactory.newInstance().newTransformer().transform( new DOMSource( document ), new StreamResult( System.out ) );
} catch ( Exception e ) {
e.printStackTrace();
}
}
它工作正常,但不知道发生了什么,它开始给我和错误如下:参考类似的帖子..但是dint得到了解决方案我没有在VM级别设置任何参数。
java.net.SocketException: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: sun.security.ssl.SSLContextImpl$DefaultSSLContext)
at javax.net.ssl.DefaultSSLSocketFactory.throwException(Unknown Source)
at javax.net.ssl.DefaultSSLSocketFactory.createSocket(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.afterConnect(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
我找到了这个错误的根本原因。导入.p12文件时,它给我和错误 - >文件无效,可用作以下内容:个人信息交换。我该如何解决这个问题?