@@ -57,9 +57,6 @@ internal final class _EasyHandle {
57
57
fileprivate var pauseState : _PauseState = [ ]
58
58
internal var timeoutTimer : _TimeoutSource !
59
59
internal lazy var errorBuffer = [ UInt8] ( repeating: 0 , count: Int ( CFURLSessionEasyErrorSize) )
60
- #if os(Android)
61
- static fileprivate var _CAInfoFile : UnsafeMutablePointer < Int8 > ?
62
- #endif
63
60
64
61
init ( delegate: _EasyHandleDelegate ) {
65
62
self . delegate = delegate
@@ -172,20 +169,20 @@ extension _EasyHandle {
172
169
let protocols = ( CFURLSessionProtocolHTTP | CFURLSessionProtocolHTTPS)
173
170
try ! CFURLSession_easy_setopt_long ( rawHandle, CFURLSessionOptionPROTOCOLS, protocols) . asError ( )
174
171
try ! CFURLSession_easy_setopt_long ( rawHandle, CFURLSessionOptionREDIR_PROTOCOLS, protocols) . asError ( )
175
- #if os(Android)
176
- // See https://curl.haxx.se/docs/sslcerts.html
177
- // For SSL to work you need "cacert.pem" to be accessable
178
- // at the path pointed to by the URLSessionCAInfo env var.
179
- // Downloadable here: https://curl.haxx.se/ca/cacert.pem
180
- if let caInfo = _EasyHandle. _CAInfoFile {
181
- if String ( cString: caInfo) == " UNSAFE_SSL_NOVERIFY " {
182
- try ! CFURLSession_easy_setopt_int ( rawHandle, CFURLSessionOptionSSL_VERIFYPEER, 0 ) . asError ( )
183
- }
184
- else {
185
- try ! CFURLSession_easy_setopt_ptr ( rawHandle, CFURLSessionOptionCAINFO, caInfo) . asError ( )
186
- }
172
+ #if os(Android)
173
+ // See https://curl.haxx.se/docs/sslcerts.html
174
+ // For SSL on Android you need a "cacert.pem" to be
175
+ // accessible at the path pointed to by this env var.
176
+ // Downloadable here: https://curl.haxx.se/ca/cacert.pem
177
+ if let caInfo = getenv ( " URLSessionCertificateAuthorityInfoFile " ) {
178
+ if String ( cString: caInfo) == " INSECURE_SSL_NO_VERIFY " {
179
+ try ! CFURLSession_easy_setopt_long ( rawHandle, CFURLSessionOptionSSL_VERIFYPEER, 0 ) . asError ( )
180
+ }
181
+ else {
182
+ try ! CFURLSession_easy_setopt_ptr ( rawHandle, CFURLSessionOptionCAINFO, caInfo) . asError ( )
187
183
}
188
- #endif
184
+ }
185
+ #endif
189
186
//TODO: Added in libcurl 7.45.0
190
187
//TODO: Set default protocol for schemeless URLs
191
188
//CURLOPT_DEFAULT_PROTOCOL available only in libcurl 7.45.0
@@ -632,19 +629,6 @@ extension _EasyHandle._CurlStringList {
632
629
}
633
630
}
634
631
635
- #if os(Android)
636
- extension URLSession {
637
-
638
- public static func setCAInfoFile( _ _CAInfoFile: String ) {
639
- free ( _EasyHandle. _CAInfoFile)
640
- _CAInfoFile. withCString {
641
- _EasyHandle. _CAInfoFile = strdup ( $0)
642
- }
643
- }
644
-
645
- }
646
- #endif
647
-
648
632
extension CFURLSessionEasyCode : Equatable {
649
633
public static func == ( lhs: CFURLSessionEasyCode , rhs: CFURLSessionEasyCode ) -> Bool {
650
634
return lhs. value == rhs. value
0 commit comments