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