java中post重复请求_如何在Java中发布HTTPS post请求? [重复]

这个问题在这里已有答案:

我正在尝试发布HTTPS帖子请求 .

String url = "https://myhttpsurl.com"

URL myurl = new URL(url);

HttpsURLConnection con = (HttpsURLConnection) myurl.openConnection();

con.setRequestMethod("POST");

String query = "confirmation_number=" + URLEncoder.encode(confNumber, "UTF-8");

con.setRequestProperty("Content-length",String.valueOf(query.length()));

con.setRequestProperty("Content-Type","application/x-www-form-urlencoded");

con.setDoOutput(true);

con.setDoInput(true);

DataOutputStream output = new DataOutputStream(con.getOutputStream());

output.writeBytes(query);

output.close();

System.out.println("Resp Code:"+con.getResponseCode());

我收到以下错误:

javax.net.ssl.SSLHandshakeException:sun.security.validator.ValidatorException:PKIX路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:无法在sun.security.ssl.Alerts找到所请求目标的有效证书路径 . get.SLException(Alerts.java:192)at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1904)at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:279)at sun.security.ssl.Handshaker .fatalSE(Handshaker.java:273)at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1446)at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:209)at sun.security.ssl . Handshaker.processLoop(Handshaker.java:913)at sun.security.ssl.Handshaker.process_record(Handshaker.java:849)at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1023)at sun.security.ssl .SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1332)at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1359)at sun .security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1343)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.getOutputStream(HttpURLConnection.java:1092)at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:250)

请提出导致错误的原因

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值