Thank you!
Downloading cacert.pem and setting path into environment variable URLSessionCertificateAuthorityInfoFile seems helps.
File certificatesFile = this.getCachedAsset(this, "cacert.pem");
Os.setenv("URLSessionCertificateAuthorityInfoFile", certificatesFile.getAbsolutePath(), true);
// Or alternative !!!unsafe!!! way.
Os.setenv("URLSessionCertificateAuthorityInfoFile", "INSECURE_SSL_NO_VERIFY", true);
But now I am getting another error:
A/SwiftRuntime: Fatal error: Unexpected ubrk_open failure: file /ToolChain/Sources/swift/stdlib/public/core/ThreadLocalStorage.swift, line 165
The related code in file ThreadLocalStorage.swift:
@_silgen_name("_stdlib_createTLS")
internal func _createThreadLocalStorage()
-> UnsafeMutablePointer<_ThreadLocalStorage>
{
// Allocate and initialize a UBreakIterator and UText.
var err = __swift_stdlib_U_ZERO_ERROR
let newUBreakIterator = __swift_stdlib_ubrk_open(
/*type:*/ __swift_stdlib_UBRK_CHARACTER, /*locale:*/ nil,
/*text:*/ nil, /*textLength:*/ 0, /*status:*/ &err)
_precondition(err.isSuccess, "Unexpected ubrk_open failure")
// utext_openUTF8 needs a valid pointer, even though we won't read from it
var a: Int8 = 0x41
let newUText = __swift_stdlib_utext_openUTF8(
/*ut:*/ nil, /*s:*/ &a, /*len:*/ 1, /*status:*/ &err)
_precondition(err.isSuccess, "Unexpected utext_openUTF8 failure")
let tlsPtr: UnsafeMutablePointer<_ThreadLocalStorage>
= UnsafeMutablePointer<_ThreadLocalStorage>.allocate(
capacity: 1
)
tlsPtr.initialize(to: _ThreadLocalStorage(
_uBreakIterator: newUBreakIterator, _uText: newUText))
return tlsPtr
}
Seems like it is something addressed UBreakIterator from ICU.
File: stdlib/public/stubs/UnicodeNormalization.cpp
swift::__swift_stdlib_UBreakIterator *swift::__swift_stdlib_ubrk_open(
swift::__swift_stdlib_UBreakIteratorType type, const char *locale,
const __swift_stdlib_UChar *text, int32_t textLength,
__swift_stdlib_UErrorCode *status) {
return ptr_cast<swift::__swift_stdlib_UBreakIterator>(
ubrk_open(static_cast<UBreakIteratorType>(type), locale,
reinterpret_cast<const UChar *>(text), textLength,
ptr_cast<UErrorCode>(status)));
}
Maybe ICU is not properly configured on runtime (i.e. environment variables)?