1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package io.netty.handler.ssl;
18
19 import io.netty.util.ReferenceCounted;
20 import io.netty.util.internal.UnstableApi;
21
22 import java.security.Provider;
23
24
25
26
27 public enum SslProvider {
28
29
30
31 JDK,
32
33
34
35 OPENSSL,
36
37
38
39 @UnstableApi
40 OPENSSL_REFCNT;
41
42
43
44
45
46 @SuppressWarnings("deprecation")
47 public static boolean isAlpnSupported(final SslProvider provider) {
48 switch (provider) {
49 case JDK:
50 return JdkAlpnApplicationProtocolNegotiator.isAlpnSupported();
51 case OPENSSL:
52 case OPENSSL_REFCNT:
53 return OpenSsl.isAlpnSupported();
54 default:
55 throw new Error("Unknown SslProvider: " + provider);
56 }
57 }
58
59
60
61
62
63 public static boolean isTlsv13Supported(final SslProvider sslProvider) {
64 return isTlsv13Supported(sslProvider, null);
65 }
66
67
68
69
70
71 public static boolean isTlsv13Supported(final SslProvider sslProvider, Provider provider) {
72 switch (sslProvider) {
73 case JDK:
74 return SslUtils.isTLSv13SupportedByJDK(provider);
75 case OPENSSL:
76 case OPENSSL_REFCNT:
77 return OpenSsl.isTlsv13Supported();
78 default:
79 throw new Error("Unknown SslProvider: " + sslProvider);
80 }
81 }
82
83
84
85
86
87 public static boolean isOptionSupported(SslProvider sslProvider, SslContextOption<?> option) {
88 switch (sslProvider) {
89 case JDK:
90
91 return false;
92 case OPENSSL:
93 case OPENSSL_REFCNT:
94 return OpenSsl.isOptionSupported(option);
95 default:
96 throw new Error("Unknown SslProvider: " + sslProvider);
97 }
98 }
99
100
101
102
103
104 static boolean isTlsv13EnabledByDefault(final SslProvider sslProvider, Provider provider) {
105 switch (sslProvider) {
106 case JDK:
107 return SslUtils.isTLSv13EnabledByJDK(provider);
108 case OPENSSL:
109 case OPENSSL_REFCNT:
110 return OpenSsl.isTlsv13Supported();
111 default:
112 throw new Error("Unknown SslProvider: " + sslProvider);
113 }
114 }
115 }