'Problem with JDK 8 vs JDK 15 Jersey WebResource
I have a problem with a web resource. I am requesting data from a server. If I run the program with JDK 15, everything works without problems. When I run the program with JDK 8 I get the error 403 from the server. I don't know if that has anything to do with it, but this server was switched from TLS 1.1 to TLS 1.2 before. As far as I know, JDK8 should also be able to work with TLS 1.2. The query worked before the changeover.
Client restClient = Client.create();
WebResource webResource = restClient.resource(url);
ClientResponse resp = webResource.header("Authorization", "Basic " + authStringEnc)
.get(ClientResponse.class);
if(resp.getStatus() != 200){
System.err.println("Unable to connect to the server. Code " + resp.getStatus());
}
Many thanks for your help.
Steffi
Update: Thank you for your help. After running ( -Djavax.net.debug=all) I got the following message:
0000: 48 54 54 50 2F 31 2E 31 20 34 30 33 20 46 6F 72 HTTP/1.1 403 For
0010: 62 69 64 64 65 6E 0D 0A 44 61 74 65 3A 20 4D 6F bidden..Date: Mo
0020: 6E 2C 20 32 31 20 4D 61 72 20 32 30 32 32 20 30 n, 21 Mar 2022 0
0030: 39 3A 30 39 3A 35 31 20 47 4D 54 0D 0A 43 6F 6E 9:09:51 GMT..Con
0040: 74 65 6E 74 2D 54 79 70 65 3A 20 74 65 78 74 2F tent-Type: text/
0050: 70 6C 61 69 6E 3B 20 63 68 61 72 73 65 74 3D 55 plain; charset=U
0060: 54 46 2D 38 0D 0A 43 6F 6E 74 65 6E 74 2D 4C 65 TF-8..Content-Le
0070: 6E 67 74 68 3A 20 31 36 0D 0A 43 6F 6E 6E 65 63 ngth: 16..Connec
0080: 74 69 6F 6E 3A 20 6B 65 65 70 2D 61 6C 69 76 65 tion: keep-alive
0090: 0D 0A 58 2D 46 72 61 6D 65 2D 4F 70 74 69 6F 6E ..X-Frame-Option
00A0: 73 3A 20 53 41 4D 45 4F 52 49 47 49 4E 0D 0A 52 s: SAMEORIGIN..R
00B0: 65 66 65 72 72 65 72 2D 50 6F 6C 69 63 79 3A 20 eferrer-Policy:
00C0: 73 61 6D 65 2D 6F 72 69 67 69 6E 0D 0A 43 61 63 same-origin..Cac
00D0: 68 65 2D 43 6F 6E 74 72 6F 6C 3A 20 70 72 69 76 he-Control: priv
00E0: 61 74 65 2C 20 6D 61 78 2D 61 67 65 3D 30 2C 20 ate, max-age=0,
00F0: 6E 6F 2D 73 74 6F 72 65 2C 20 6E 6F 2D 63 61 63 no-store, no-cac
0100: 68 65 2C 20 6D 75 73 74 2D 72 65 76 61 6C 69 64 he, must-revalid
0110: 61 74 65 2C 20 70 6F 73 74 2D 63 68 65 63 6B 3D ate, post-check=
0120: 30 2C 20 70 72 65 2D 63 68 65 63 6B 3D 30 0D 0A 0, pre-check=0..
0130: 45 78 70 69 72 65 73 3A 20 54 68 75 2C 20 30 31 Expires: Thu, 01
0140: 20 4A 61 6E 20 31 39 37 30 20 30 30 3A 30 30 3A Jan 1970 00:00:
0150: 30 31 20 47 4D 54 0D 0A 45 78 70 65 63 74 2D 43 01 GMT..Expect-C
0160: 54 3A 20 6D 61 78 2D 61 67 65 3D 36 30 34 38 30 T: max-age=60480
0170: 30 2C 20 72 65 70 6F 72 74 2D 75 72 69 3D 22 68 0, report-uri="h
0180: 74 74 70 73 3A 2F 2F 72 65 70 6F 72 74 2D 75 72 ttps://report-ur
0190: 69 2E 63 6C 6F 75 64 66 6C 61 72 65 2E 63 6F 6D i.cloudflare.com
01A0: 2F 63 64 6E 2D 63 67 69 2F 62 65 61 63 6F 6E 2F /cdn-cgi/beacon/
01B0: 65 78 70 65 63 74 2D 63 74 22 0D 0A 53 65 72 76 expect-ct"..Serv
01C0: 65 72 3A 20 63 6C 6F 75 64 66 6C 61 72 65 0D 0A er: cloudflare..
01D0: 43 46 2D 52 41 59 3A 20 36 65 66 35 38 64 31 36 CF-RAY: 6ef58d16
01E0: 62 39 65 30 30 66 38 65 2D 56 49 45 0D 0A 0D 0A b9e00f8e-VIE....
01F0: 65 72 72 6F 72 20 63 6F 64 65 3A 20 31 30 31 30 error code: 1010
Solution 1:[1]
The server operator has disabled the Browser Integrity Check for the endpoint of the Order API. The queries are now working again. I just don't quite understand why it still worked with version JDK15?
Many thanks to Kayaman for his help.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Steffi |
