@@ -37,18 +37,32 @@ extension TLSVersion {
37
37
}
38
38
}
39
39
40
+ /* Only use this in code that is used for compatibility with old OSes. */
41
+ protocol SSLProtocolDeprecationWarningsSilenced {
42
+ static var tlsProtocol1 : SSLProtocol { get }
43
+ static var tlsProtocol11 : SSLProtocol { get }
44
+ static var tlsProtocol12 : SSLProtocol { get }
45
+ static var tlsProtocol13 : SSLProtocol { get }
46
+
47
+ }
48
+
49
+ extension SSLProtocol : SSLProtocolDeprecationWarningsSilenced { }
50
+
40
51
extension TLSVersion {
41
52
/// return as SSL protocol
42
- var sslProtocol : SSLProtocol {
53
+ var sslProtocolDeprecatedOnlyUseCompatibilityCode : SSLProtocol {
54
+ if #available( macOS 10 . 15 , iOS 13 . 0 , tvOS 13 . 0 , watchOS 6 . 0 , * ) {
55
+ fatalError ( " please use this code only on old OS versions " )
56
+ }
43
57
switch self {
44
58
case . tlsv1:
45
- return . tlsProtocol1
59
+ return ( SSLProtocol . self as SSLProtocolDeprecationWarningsSilenced . Type ) . tlsProtocol1
46
60
case . tlsv11:
47
- return . tlsProtocol11
61
+ return ( SSLProtocol . self as SSLProtocolDeprecationWarningsSilenced . Type ) . tlsProtocol11
48
62
case . tlsv12:
49
- return . tlsProtocol12
63
+ return ( SSLProtocol . self as SSLProtocolDeprecationWarningsSilenced . Type ) . tlsProtocol12
50
64
case . tlsv13:
51
- return . tlsProtocol13
65
+ return ( SSLProtocol . self as SSLProtocolDeprecationWarningsSilenced . Type ) . tlsProtocol13
52
66
}
53
67
}
54
68
}
@@ -90,17 +104,19 @@ extension TLSConfiguration {
90
104
91
105
// minimum TLS protocol
92
106
if #available( macOS 10 . 15 , iOS 13 . 0 , tvOS 13 . 0 , watchOS 6 . 0 , * ) {
93
- sec_protocol_options_set_min_tls_protocol_version ( options. securityProtocolOptions, self . minimumTLSVersion. nwTLSProtocolVersion)
107
+ sec_protocol_options_set_min_tls_protocol_version ( options. securityProtocolOptions,
108
+ self . minimumTLSVersion. nwTLSProtocolVersion)
94
109
} else {
95
- sec_protocol_options_set_tls_min_version ( options. securityProtocolOptions, self . minimumTLSVersion. sslProtocol )
110
+ sec_protocol_options_set_tls_min_version ( options. securityProtocolOptions, self . minimumTLSVersion. sslProtocolDeprecatedOnlyUseCompatibilityCode )
96
111
}
97
112
98
113
// maximum TLS protocol
99
114
if let maximumTLSVersion = self . maximumTLSVersion {
100
115
if #available( macOS 10 . 15 , iOS 13 . 0 , tvOS 13 . 0 , watchOS 6 . 0 , * ) {
101
- sec_protocol_options_set_max_tls_protocol_version ( options. securityProtocolOptions, maximumTLSVersion. nwTLSProtocolVersion)
116
+ sec_protocol_options_set_max_tls_protocol_version ( options. securityProtocolOptions,
117
+ maximumTLSVersion. nwTLSProtocolVersion)
102
118
} else {
103
- sec_protocol_options_set_tls_max_version ( options. securityProtocolOptions, maximumTLSVersion. sslProtocol )
119
+ sec_protocol_options_set_tls_max_version ( options. securityProtocolOptions, maximumTLSVersion. sslProtocolDeprecatedOnlyUseCompatibilityCode )
104
120
}
105
121
}
106
122
0 commit comments