I have a question about running a unit (integratio...
# multiplatform
s
I have a question about running a unit (integration) test, on
commonMain
that calls a remote api that is configured by a 3rd party library (I have no control over that API, how and when it's called). When running a similar unit-test on iOS on XCode (that calls that 3rd party SDK that issues that remote request), all works well. When running the unit-test for the android-target, all works well. When running the unit-test for the iosX64-target, I get an error:
Domain=NSURLErrorDomain Code=-1202 "The certificate for this server is invalid. ... ...
Does anyone know why this error is raised when running ios-tests on KMP, and how to get rid of it? (also, the error contains this hint:
NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?
... bit odd 🙂). Thank you!
Full stack-trace here:
Copy code
kotlin.RuntimeException: GoogleGenerativeAI.GenerateContentError.internalError(underlying: Error Domain=NSURLErrorDomain Code=-1202 "The certificate for this server is invalid. You might be connecting to a server that is pretending to be "generativelanguage.googleapis.com" which could put your confidential information at risk." UserInfo={NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, _kCFStreamErrorDomainKey=3, NSErrorPeerCertificateChainKey=(
    "<cert(0x11001ce00) s: upload.video.google.com i: GTS CA 1C3>",
    "<cert(0x11001d800) s: GTS CA 1C3 i: GTS Root R1>",
    "<cert(0x11001e200) s: GTS Root R1 i: GlobalSign Root CA>"
), NSErrorClientCertificateStateKey=0, NSErrorFailingURLKey=<https://generativelanguage.googleapis.com/v1/models/gemini-pro:generateContent>, NSErrorFailingURLStringKey=<https://generativelanguage.googleapis.com/v1/models/gemini-pro:generateContent>, NSUnderlyingError=0x600000c117a0 {Error Domain=kCFErrorDomainCFNetwork Code=-1202 "(null)" UserInfo={_kCFStreamPropertySSLClientCertificateState=0, kCFStreamPropertySSLPeerTrust=<SecTrustRef: 0x6000033017c0>, _kCFNetworkCFStreamSSLErrorOriginalValue=-9807, _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=-9807, kCFStreamPropertySSLPeerCertificates=(
    "<cert(0x11001ce00) s: upload.video.google.com i: GTS CA 1C3>",
    "<cert(0x11001d800) s: GTS CA 1C3 i: GTS Root R1>",
    "<cert(0x11001e200) s: GTS Root R1 i: GlobalSign Root CA>"
)}}, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalDataTask <95EF2494-57D8-4A12-A09F-5FF6471392E0>.<1>"
), _kCFStreamErrorCodeKey=-9807, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <95EF2494-57D8-4A12-A09F-5FF6471392E0>.<1>, NSURLErrorFailingURLPeerTrustErrorKey=<SecTrustRef: 0x6000033017c0>, NSLocalizedDescription=The certificate for this server is invalid. You might be connecting to a server that is pretending to be "generativelanguage.googleapis.com" which could put your confidential information at risk.})
	at kotlin.Throwable#<init>(/opt/buildAgent/work/2fed3917837e7e79/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/Throwable.kt:28)
	at kotlin.Exception#<init>(/opt/buildAgent/work/2fed3917837e7e79/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/Exceptions.kt:23)
    ...
    ...
r
The default KN test setup runs the simulator in a standalone mode which is missing a bunch of entitlements/certs. See here for how to disable, but you're then responsible for launching the simulator yourself.
There's also some details/background at https://youtrack.jetbrains.com/issue/KT-38317
s
Thank you, Russell! Happy New Year!
cheers 2
112 Views