@@ -37,18 +37,32 @@ extension TLSVersion {
3737 }
3838}
3939
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+
4051extension TLSVersion {
4152 /// 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+ }
4357 switch self {
4458 case . tlsv1:
45- return . tlsProtocol1
59+ return ( SSLProtocol . self as SSLProtocolDeprecationWarningsSilenced . Type ) . tlsProtocol1
4660 case . tlsv11:
47- return . tlsProtocol11
61+ return ( SSLProtocol . self as SSLProtocolDeprecationWarningsSilenced . Type ) . tlsProtocol11
4862 case . tlsv12:
49- return . tlsProtocol12
63+ return ( SSLProtocol . self as SSLProtocolDeprecationWarningsSilenced . Type ) . tlsProtocol12
5064 case . tlsv13:
51- return . tlsProtocol13
65+ return ( SSLProtocol . self as SSLProtocolDeprecationWarningsSilenced . Type ) . tlsProtocol13
5266 }
5367 }
5468}
@@ -90,17 +104,19 @@ extension TLSConfiguration {
90104
91105 // minimum TLS protocol
92106 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)
94109 } 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 )
96111 }
97112
98113 // maximum TLS protocol
99114 if let maximumTLSVersion = self . maximumTLSVersion {
100115 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)
102118 } 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 )
104120 }
105121 }
106122
0 commit comments