简体   繁体   English

收到致命警报:handshake_failure webservice

[英]Received fatal alert: handshake_failure webservice

I have hired a web service that sends sms messages to mobile phone.我聘请了一个向手机发送短信的 web 服务。 I have tried to make the post request but I amb getting the error:我试图发出发布请求,但我得到了错误:

Exception in thread "main" javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure

The webservice company gave me all the information needed for making the the url: the user, the password, the params needed, the response etc网络服务公司给了我制作 url 所需的所有信息:用户、密码、所需参数、响应等

The gsm param is the mobile phone number. gsm 参数是手机号码。 msg is the message to send. 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());

        }

    }
}

Also If I tried to acces the the webservice call by writting the url to the navbar of Mozilla Firefox I got that error:此外,如果我尝试通过将 url 写入 Mozilla Firefox 的导航栏来访问 Web 服务调用,我会收到该错误:

Secure Connection Failed安全连接失败

An error occurred during a connection to 'url' SSL peer was unable to negotiate an acceptable set of security parameters.在连接到“url”时发生错误 SSL 对等方无法协商一组可接受的安全参数。

Error code: SSL_ERROR_HANDSHAKE_FAILURE_ALERT错误代码:SSL_ERROR_HANDSHAKE_FAILURE_ALERT

The page you are trying to view cannot be shown because the authenticity of the received data could not be verified.您尝试查看的页面无法显示,因为无法验证接收到的数据的真实性。

在此处输入图像描述

Given that the domain in question (push.tempos21.com) works for me with the browser but does not work for you neither with app nor browser, it is likely that it is not a problem of app or browser but of your connection to the target.鉴于有问题的域(push.tempos21.com)适用于我的浏览器,但不适用于您的应用程序或浏览器,这可能不是应用程序或浏览器的问题,而是您与目标。 I suspect that there is some deep inspection firewall or IPS somewhere in the path which allows the initial TCP connect but then blocks the traffic once the target is known from the ClientHello (start of TLS handshake).我怀疑路径中的某处存在一些深度检查防火墙或 IPS,它允许初始 TCP 连接,但一旦从 ClientHello(TLS 握手开始)知道目标,就会阻止流量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM