首页 > 解决方案 > 如何解决错误“错误请求。主机和端口的组合需要 TLS。”

问题描述

我正在尝试使用休息端点,但出现以下错误

错误请求。主机和端口的组合需要 TLS。

这是我写的代码

GET_URL ="https:/path/data"
    URL obj = new URL(GET_URL);
            HttpURLConnection con = (HttpURLConnection) obj.openConnection();
            con.setRequestMethod("GET");
            int responseCode = con.getResponseCode();
            System.out.println("GET Response Code :: " + responseCode)

下面的代码来自其他暴露其余端点的团队。休息端点已启用 SSL。当我检查它说的代码时

@RestController
public class TestController {
    @RequestMapping(value = "/data", method = RequestMethod.GET)
    public String getData() {
        
        return "Hello World";
    }

server:
  ssl:
    enabled: true
    client-auth: need
    key-store: {keystore-path}
    key-store-password: {keystore-password}
    key-alias: alias-name
    key-store-type: JKS

我该如何解决这个错误?能否提供步骤

标签: javaspring-bootsslopensslssl-certificate

解决方案


推荐阅读