繁体   English   中英

javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: 找不到主题替代 DNS 名称匹配 xxx.com

[英]javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative DNS name matching xxx.com found

我正在尝试从我的 java 应用程序连接到外部 api。我使用 jersey 发出呼叫请求

ClientConfig clientConfig = new ClientConfig();
        //Open Digest authentication
        
        clientConfig.register(JacksonFeature.class);
        //Create new rest client
        Client client = ClientBuilder.newClient( clientConfig );
        
        //Set the url
        WebTarget webTarget = client.target(rootUrl);
        Invocation.Builder invocationBuilder =  webTarget.request(javax.ws.rs.core.MediaType.APPLICATION_JSON);
        
        MultivaluedMap<String, Object> header = new MultivaluedHashMap<>();
        header.add("UserName", username);
        header.add("Password", password);
        
        invocationBuilder.headers(header);
        logger.info("Initialisation of cashout service successful");
        
        // create request
        Gson gson = new Gson();
        String transactionString = gson.toJson(request);
        
        
        
        try {
            // start the response
            Response response = invocationBuilder.put(Entity.entity(transactionString, javax.ws.rs.core.MediaType.APPLICATION_JSON));
            //We check if the response is ok
            if(response.getStatus() == 200) {
                logger.info("The paiement is done, we got 200 code return");
                responseData = response.readEntity(AirtimePaymentResponse.class);
                
                logger.info("the response data is {} ", responseData);
            }else {
                logger.info("error during the paiement");
                throw new GGException("Error during the paiement", HttpStatus.valueOf(response.getStatus()));
            }
        }catch (Exception e) {
            throw new GGException(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
        }

但是我们No subject alternative DNS name matching xxx.com found. . 我可以在我的代码中禁用 ssl 检查以便我可以在不安全模式下运行吗?

我尝试了很多解决方案但没有成功。

谢谢

您的问题与此处回答的类似问题有关: Certificate for <localhost> doesn't match any of the subject alternative names

在上面的链接中,您可以找到详细的解释,但基本上这意味着您正在调用服务器,但是您在请求中使用的主机名未在服务器证书主题备用名称 (SAN) 字段中定义。 所以我建议为带有附加 SAN 字段的服务器创建一个新证书。 我不建议禁用 ssl 检查,因为它不再安全。

暂无
暂无

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

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