Is there any known issue with OpenJDK 8 (1.8.0_232) and some HTTPS connections causing HTTP error 403?

Mar*_*nen 2 java xquery saxon basex

When running Saxon 9.9.1.6 HE with Java 1.8.0_232 (java -version outputs

openjdk version "1.8.0_232"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_232-b09)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.232-b09, mixed mode)
Run Code Online (Sandbox Code Playgroud)

) and the command line java -cp 'C:\Program Files\Saxonica\Saxon9.9HE\saxon9he.jar' net.sf.saxon.Query -t .\harry-potter-api-ex1.xq to run an XQuery program trying to access https://www.potterapi.com/v1/sortingHat I always get an error FOUT1170: Server returned HTTP response code: 403 for URL: https://www.potterapi.com/v1/sortingHat.

Running Java 12.0.1 (java -version output

openjdk version "12.0.1" 2019-04-16
OpenJDK Runtime Environment (build 12.0.1+12)
OpenJDK 64-Bit Server VM (build 12.0.1+12, mixed mode)
Run Code Online (Sandbox Code Playgroud)

) on the same machine with the same Saxon version the query always works/is able to make the HTTPS access.

Java 8/1.8 是否存在任何可能导致此问题的已知问题?是否有人使用 Oracle JRE 1.8 遇到同样的错误?

XQuery 文件是

declare namespace map = "http://www.w3.org/2005/xpath-functions/map";
declare namespace array = "http://www.w3.org/2005/xpath-functions/array";

declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";

declare option output:method 'json';
declare option output:indent 'yes';


json-doc('https://www.potterapi.com/v1/sortingHat')
Run Code Online (Sandbox Code Playgroud)

我已经用 Saxon 和 Java 8/1.8 测试了其他一些 HTTPS 连接,它们确实可以工作,但是对于给定的 URL,我总是在 Java 8/1.8 中出现错误,在 Java 12 中没有错误。

[FOUT1170] Resource 'https://www.potterapi.com/v1/sortingHat' cannot be retrieved.在使用 Java 8 运行时,BaseX 也会给我,并使用 Java 12 运行查询。

我现在也尝试了一些 Java 代码

    System.out.println(System.getProperty("java.version"));

    URL url = new URL("https://www.potterapi.com/v1/sortingHat");

    HttpURLConnection con = (HttpURLConnection)url.openConnection();

    try {
        con.connect();
        System.out.println(con.getResponseCode());
    }
    finally {
        con.disconnect();
    }
Run Code Online (Sandbox Code Playgroud)

输出是

1.8.0_232
403
Run Code Online (Sandbox Code Playgroud)

对于 Java 1.8 和

12.0.1
200
Run Code Online (Sandbox Code Playgroud)

知道什么可能导致 Java 1.8/8 出现 403?

mat*_*sev 5

这是证书/CA 信任问题。

如果您检查https://www.potterapi.com/v1/sortingHat的证书(例如通过在浏览器中打开 url 并单击挂锁图标),您会发现它是由COMODO ECC Domain Validation Secure Server CA 2.

接下来,如果您检查JEP 319:根证书的内容,您会发现 Comodo(和其他 CA)作为 Java 10 的一部分添加到 OpenJDK 中。因此,由于较旧的 Java 版本(例如 Java 8)没有 Comodo CA它的证书链,服务器(在这个例子中是potterapi)将在TLS握手期间拒绝它并以403 - Forbidden响应。