javax.net.ssl.SSLException:java.security.ProviderException:无法获得关键

问题描述 投票:0回答:1

我通过HttpsURLConnection.My发布带有参数集的Web服务JDK版本是1.8.But我从webservice.But收到错误我找不到problem.Stacktrace的解决方案是继;

      javax.net.ssl.SSLException: java.security.ProviderException: Could not derive key
at sun.security.ssl.Alerts.getSSLException(Alerts.java:208)
at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1946)
at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1903)
at sun.security.ssl.SSLSocketImpl.handleException(SSLSocketImpl.java:1886)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1402)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1379)
at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:559)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(HttpURLConnection.java:1334)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1309)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:259)
at sikke.cli.helpers.Helpers.sendPost(Helpers.java:75)
at sikke.cli.helpers.Methods.createAccountAndSave(Methods.java:538)
at sikke.cli.helpers.Methods.createAccountAndSave(Methods.java:503)
at sikke.cli.JSONRPC.Methods(JSONRPC.java:28)
at sikke.cli.EchoPostHandler.handle(EchoPostHandler.java:74)
at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:79)
at sun.net.httpserver.AuthFilter.doFilter(AuthFilter.java:83)
at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:82)
at sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(ServerImpl.java:675)
at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:79)
at sun.net.httpserver.ServerImpl$Exchange.run(ServerImpl.java:647)
at sun.net.httpserver.ServerImpl$DefaultExecutor.execute(ServerImpl.java:158)
at sun.net.httpserver.ServerImpl$Dispatcher.handle(ServerImpl.java:431)
at sun.net.httpserver.ServerImpl$Dispatcher.run(ServerImpl.java:396)
at java.lang.Thread.run(Thread.java:748)

我的如下接线柱连接方法;

public String sendPost(String path, String urlParameters) throws Exception {
    String server = system.getConf("server");
    String url = server.equals("1") ? "https:....." : "https:....";
    url += path;

    URL obj = new URL(url);
    HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();

    // add reuqest header
    con.setRequestMethod("POST");
    // con.setRequestProperty("User-Agent", USER_AGENT);
    con.setRequestProperty("Accept-Language", "en-US,en;q=0.5");

    // Send post request
    con.setDoOutput(true);
    try (DataOutputStream wr = new DataOutputStream(con.getOutputStream())) {
        wr.writeBytes(urlParameters);
        wr.flush();
    }

    int responseCode = con.getResponseCode();
    BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
    String inputLine;
    StringBuilder response = new StringBuilder();

    while ((inputLine = in.readLine()) != null) {
        response.append(inputLine);
    }
    in.close();
    return response.toString();
}

我在哪里做wrong.How我可以解决这个问题。

java web-services webservice-client httpsurlconnection
1个回答
0
投票

我有同样的问题,我固定它,当我改变了SDK。我从开放的JDK downloded java8和问题得到了解决。从这个链接Downloded - > https://openjdk.java.net/install/

© www.soinside.com 2019 - 2024. All rights reserved.