@@ -35,6 +35,22 @@ internal extension TLSVersion {
35
35
}
36
36
}
37
37
38
+ internal extension TLSVersion {
39
+ /// return as SSL protocol
40
+ var sslProtocol : SSLProtocol {
41
+ switch self {
42
+ case . tlsv1:
43
+ return . tlsProtocol1
44
+ case . tlsv11:
45
+ return . tlsProtocol11
46
+ case . tlsv12:
47
+ return . tlsProtocol12
48
+ case . tlsv13:
49
+ return . tlsProtocol13
50
+ }
51
+ }
52
+ }
53
+
38
54
@available ( macOS 10 . 14 , iOS 12 . 0 , tvOS 12 . 0 , watchOS 6 . 0 , * )
39
55
internal extension TLSConfiguration {
40
56
@@ -51,28 +67,25 @@ internal extension TLSConfiguration {
51
67
// minimum TLS protocol
52
68
if #available( macOS 10 . 15 , iOS 13 . 0 , tvOS 13 . 0 , watchOS 6 . 0 , * ) {
53
69
sec_protocol_options_set_min_tls_protocol_version ( options. securityProtocolOptions, self . minimumTLSVersion. nwTLSProtocolVersion)
70
+ } else {
71
+ sec_protocol_options_set_tls_min_version ( options. securityProtocolOptions, self . minimumTLSVersion. sslProtocol)
54
72
}
55
73
56
74
// maximum TLS protocol
57
75
if let maximumTLSVersion = self . maximumTLSVersion {
58
76
if #available( macOS 10 . 15 , iOS 13 . 0 , tvOS 13 . 0 , watchOS 6 . 0 , * ) {
59
77
sec_protocol_options_set_max_tls_protocol_version ( options. securityProtocolOptions, maximumTLSVersion. nwTLSProtocolVersion)
60
78
} else {
61
- precondition ( self . maximumTLSVersion != nil , " TLSConfiguration. maximumTLSVersion is not supported " )
79
+ sec_protocol_options_set_tls_max_version ( options . securityProtocolOptions , maximumTLSVersion. sslProtocol )
62
80
}
63
81
}
64
82
65
83
// application protocols
66
- if self . applicationProtocols. count > 0 {
67
- preconditionFailure ( " TLSConfiguration.applicationProtocols is not supported " )
68
- }
69
- /*for applicationProtocol in self.applicationProtocols {
70
- applicationProtocol.utf8.withContiguousStorageIfAvailable { buffer in
71
- guard let opaquePointer = OpaquePointer(buffer.baseAddress) else { return }
72
- let int8Pointer = UnsafePointer<Int8>(opaquePointer)
73
- sec_protocol_options_add_tls_application_protocol(options.securityProtocolOptions, int8Pointer)
84
+ for applicationProtocol in self . applicationProtocols {
85
+ applicationProtocol. withCString { buffer in
86
+ sec_protocol_options_add_tls_application_protocol ( options. securityProtocolOptions, buffer)
74
87
}
75
- }*/
88
+ }
76
89
77
90
// the certificate chain
78
91
if self . certificateChain. count > 0 {
0 commit comments