java使用阿里云短信服务报异常

java使用阿里云短信服务,CommonResponse response = client.getCommonResponse(request); 这行代码报错,javax.net.ssl.SSLException: Unsupported or unrecognized SSL message,这是https的请求,如果换成http就不报异常,正常运行完,但是收不到短信,求解决。。。

应该是SSL/TLS协议配置那里有没有加这个选定协议版本的配置,

System.setProperty("https.protocols", "TLSv1.2");
在发送https请求之前要吧上面配置写上,如果还有问题请问阿里云专业人士,他们的服务应该有包括这个

发送短信的代码参考:

  /**
     * 发送短信
     *
     * @param phoneNumber 手机号
     * @param code        验证码
     * @return 返回结果
     */
    @Override
    @SneakyThrows
    public BaseResult sendMessage(String phoneNumber, String code) {
        // 工程代码泄露可能会导致AccessKey泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考,建议使用更安全的 STS 方式,更多鉴权访问方式请参见:https://help.aliyun.com/document_detail/378657.html
            Client client = createClient(accessKeyId, accessKeySecret);
            SendSmsRequest sendSmsRequest = new SendSmsRequest()
                    .setSignName("阿里云短信测试")
                    .setTemplateCode("SMS_154xxxx09")
                    .setPhoneNumbers("1392xxxx410")
                    .setTemplateParam("{\"code\":\""+code+"\"}");
            RuntimeOptions runtime = new RuntimeOptions();
            // 复制代码运行请自行打印 API 的返回值
        SendSmsResponse response = client.sendSmsWithOptions(sendSmsRequest, runtime);
        SendSmsResponseBody body = response.getBody();
        String code1 = body.getCode();
        if ("OK".equals(code1)){
            return BaseResult.ok();
        }
        return new BaseResult(500,body.getMessage(),null);
    }

另外不知道你代码其他地方有没有问题,强烈建议你撸一遍这个博文,仔细对比一下详细步骤,或者直接用博文的博主也可以
https://blog.csdn.net/m0_58847451?type=blog