Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/sun/security/ssl/SignatureScheme/SigAlgosExtTestWithTLS13.java
41152 views
1
/*
2
* Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
/*
25
* @test 8263188
26
* @summary If TLS the server and client has no common signature algorithms,
27
* the connection should fail fast with "No supported signature algorithm".
28
* This test only covers TLS 1.3, but doesn't cover client authentication.
29
*
30
* @library /test/lib
31
* /javax/net/ssl/templates
32
*
33
* @run main/othervm
34
* -Djdk.tls.server.SignatureSchemes=ecdsa_secp384r1_sha384
35
* -Djdk.tls.client.SignatureSchemes=ecdsa_secp256r1_sha256,ecdsa_secp384r1_sha384
36
* -Dtest.expectFail=false
37
* SigAlgosExtTestWithTLS13
38
* @run main/othervm
39
* -Djdk.tls.server.SignatureSchemes=ecdsa_secp384r1_sha384
40
* -Djdk.tls.client.SignatureSchemes=ecdsa_secp256r1_sha256
41
* -Dtest.expectFail=true
42
* SigAlgosExtTestWithTLS13
43
*/
44
45
import javax.net.ssl.SSLContext;
46
import javax.net.ssl.SSLHandshakeException;
47
import javax.net.ssl.SSLSocket;
48
49
public class SigAlgosExtTestWithTLS13 extends SSLSocketTemplate {
50
51
@Override
52
protected SSLContext createServerSSLContext() throws Exception {
53
return createSSLContext(
54
new Cert[] { Cert.CA_ECDSA_SECP256R1, Cert.CA_ECDSA_SECP384R1 },
55
new Cert[] { Cert.EE_ECDSA_SECP256R1, Cert.EE_ECDSA_SECP384R1 },
56
getServerContextParameters());
57
}
58
59
@Override
60
protected SSLContext createClientSSLContext() throws Exception {
61
return createSSLContext(
62
new Cert[] { Cert.CA_ECDSA_SECP256R1, Cert.CA_ECDSA_SECP384R1 },
63
new Cert[] { Cert.EE_ECDSA_SECP256R1, Cert.EE_ECDSA_SECP384R1 },
64
getClientContextParameters());
65
}
66
67
@Override
68
protected void configureClientSocket(SSLSocket socket) {
69
socket.setEnabledProtocols(new String[] { "TLSv1.3" });
70
}
71
72
public static void main(String[] args) throws Exception {
73
boolean expectFail = Boolean.getBoolean("test.expectFail");
74
try {
75
new SigAlgosExtTestWithTLS13().run();
76
if (expectFail) {
77
throw new RuntimeException(
78
"Expected SSLHandshakeException wasn't thrown");
79
}
80
} catch (SSLHandshakeException e) {
81
if (expectFail && e.getMessage().equals(
82
"No supported signature algorithm")) {
83
System.out.println("Expected SSLHandshakeException");
84
} else {
85
throw e;
86
}
87
}
88
}
89
}
90
91