收到致命警报:handshake_failure 网络服务
Received fatal alert: handshake_failure webservice
我雇用了一项网络服务,可以向手机发送短信 phone。我已尝试发出 post 请求,但收到错误消息:
Exception in thread "main" javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
网络服务公司给了我制作 url 所需的所有信息:用户、密码、所需的参数、响应等
gsm 参数是手机 phone 号码。
msg 是要发送的消息。
import java.net.HttpURLConnection;
import javax.net.ssl.HttpsURLConnection;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.URL;
public class Test3 {
public static void main(String[] args) throws Exception {
Test3 obj = new Test3();
System.out.println("Testing 1 - Send Http POST request");
obj.sendPost();
}
private void sendPost() throws Exception {
//
String url = "https://...url/send";//(that url its just an example, its not the real)
HttpsURLConnection httpClient = (HttpsURLConnection) new URL(url).openConnection();
//add reuqest header
httpClient.setRequestMethod("POST");
httpClient.setRequestProperty("User-Agent", "Mozilla/5.0");
httpClient.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
String urlParameters = "?user=TEST_USER&company=XXX&passwd=TEST_PWD&gsm=666000222&type=plus&msg=hello&sender=me";
// Send post request
httpClient.setDoOutput(true);
try (DataOutputStream wr = new DataOutputStream(httpClient.getOutputStream())) {
wr.writeBytes(urlParameters);
wr.flush();
}
int responseCode = httpClient.getResponseCode();
System.out.println("\nSending 'POST' request to URL : " + url);
System.out.println("Post parameters : " + urlParameters);
System.out.println("Response Code : " + responseCode);
try (BufferedReader in = new BufferedReader(
new InputStreamReader(httpClient.getInputStream()))) {
String line;
StringBuilder response = new StringBuilder();
while ((line = in.readLine()) != null) {
response.append(line);
}
System.out.println(response.toString());
}
}
}
此外,如果我试图通过将 url 写入 Mozilla Firefox 的导航栏来访问 Web 服务调用,我会收到该错误:
安全连接失败
连接到 'url' SSL 对等方时发生错误,无法协商一组可接受的安全参数。
错误代码:SSL_ERROR_HANDSHAKE_FAILURE_ALERT
无法显示您尝试查看的页面,因为无法验证接收到的数据的真实性。
考虑到有问题的域 (push.tempos21.com) 适用于我的浏览器,但不适用于您的应用程序或浏览器,这很可能不是应用程序或浏览器的问题浏览器,但您与目标的连接。我怀疑路径中某处有一些深度检查防火墙或 IPS,它允许初始 TCP 连接,但一旦从 ClientHello 获知目标(TLS 握手开始)就会阻止流量。
我雇用了一项网络服务,可以向手机发送短信 phone。我已尝试发出 post 请求,但收到错误消息:
Exception in thread "main" javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
网络服务公司给了我制作 url 所需的所有信息:用户、密码、所需的参数、响应等
gsm 参数是手机 phone 号码。 msg 是要发送的消息。
import java.net.HttpURLConnection;
import javax.net.ssl.HttpsURLConnection;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.URL;
public class Test3 {
public static void main(String[] args) throws Exception {
Test3 obj = new Test3();
System.out.println("Testing 1 - Send Http POST request");
obj.sendPost();
}
private void sendPost() throws Exception {
//
String url = "https://...url/send";//(that url its just an example, its not the real)
HttpsURLConnection httpClient = (HttpsURLConnection) new URL(url).openConnection();
//add reuqest header
httpClient.setRequestMethod("POST");
httpClient.setRequestProperty("User-Agent", "Mozilla/5.0");
httpClient.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
String urlParameters = "?user=TEST_USER&company=XXX&passwd=TEST_PWD&gsm=666000222&type=plus&msg=hello&sender=me";
// Send post request
httpClient.setDoOutput(true);
try (DataOutputStream wr = new DataOutputStream(httpClient.getOutputStream())) {
wr.writeBytes(urlParameters);
wr.flush();
}
int responseCode = httpClient.getResponseCode();
System.out.println("\nSending 'POST' request to URL : " + url);
System.out.println("Post parameters : " + urlParameters);
System.out.println("Response Code : " + responseCode);
try (BufferedReader in = new BufferedReader(
new InputStreamReader(httpClient.getInputStream()))) {
String line;
StringBuilder response = new StringBuilder();
while ((line = in.readLine()) != null) {
response.append(line);
}
System.out.println(response.toString());
}
}
}
此外,如果我试图通过将 url 写入 Mozilla Firefox 的导航栏来访问 Web 服务调用,我会收到该错误:
安全连接失败
连接到 'url' SSL 对等方时发生错误,无法协商一组可接受的安全参数。
错误代码:SSL_ERROR_HANDSHAKE_FAILURE_ALERT
无法显示您尝试查看的页面,因为无法验证接收到的数据的真实性。
考虑到有问题的域 (push.tempos21.com) 适用于我的浏览器,但不适用于您的应用程序或浏览器,这很可能不是应用程序或浏览器的问题浏览器,但您与目标的连接。我怀疑路径中某处有一些深度检查防火墙或 IPS,它允许初始 TCP 连接,但一旦从 ClientHello 获知目标(TLS 握手开始)就会阻止流量。