Uploaded image for project: 'Realm Kotlin'
  1. Realm Kotlin
  2. RKOTLIN-411

Realm Sync failure on IOS due to SSL certificate

      Hi folks!

      When set up Realm Sync my tests are failing with the following error:

      io.realm.mongodb.AppException: io.ktor.client.engine.ios.IosHttpRequestException: Exception in http request: Error Domain=NSURLErrorDomain Code=-1202 "The certificate for this server is invalid. You might be connecting to a server that is pretending to be “realm.mongodb.com” which could put your confidential information at risk." UserInfo={NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, _kCFStreamErrorDomainKey=3, NSErrorPeerCertificateChainKey=(
          "<cert(0x7fe55300de00) s: *.realm.mongodb.com i: DigiCert SHA2 Secure Server CA>",
          "<cert(0x7fe553012600) s: DigiCert SHA2 Secure Server CA i: DigiCert Global Root CA>"
      ), NSErrorClientCertificateStateKey=0, NSErrorFailingURLKey=https://realm.mongodb.com/api/client/v2.0/app/<app-id>/location, NSErrorFailingURLStringKey=https://realm.mongodb.com/api/client/v2.0/app/<app-id>/location, NSUnderlyingError=0x600000826010 {Error Domain=kCFErrorDomainCFNetwork Code=-1202 "(null)" UserInfo={_kCFStreamPropertySSLClientCertificateState=0, kCFStreamPropertySSLPeerTrust=<SecTrustRef: 0x6000037140a0>, _kCFNetworkCFStreamSSLErrorOriginalValue=-9807, _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=-9807, kCFStreamPropertySSLPeerCertificates=(
          "<cert(0x7fe55300de00) s: *.realm.mongodb.com i: DigiCert SHA2 Secure Server CA>",
          "<cert(0x7fe553012600) s: DigiCert SHA2 Secure Server CA i: DigiCert Global Root CA>"
      )}}, _NSURLErrorRelatedURLSessionTaskErrorKey=(
          "LocalDataTask <73B00916-402A-48F7-A342-ED5233E210B8>.<1>"
      ), _kCFStreamErrorCodeKey=-9807, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <73B00916-402A-48F7-A342-ED5233E210B8>.<1>, NSURLErrorFailingURLPeerTrustErrorKey=<SecTrustRef: 0x6000037140a0>, NSLocalizedDescription=The certificate for this server is invalid. You might be connecting to a server that is pretending to be “realm.mongodb.com” which could put your confidential information at risk.} [error_category=4, error_code=1000, link_to_server_logs=null]
      	at kotlin.Throwable#<init>(/Users/teamcity1/teamcity_work/6326934d18cfe24e/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/Throwable.kt:24)
      	at kotlin.Exception#<init>(/Users/teamcity1/teamcity_work/6326934d18cfe24e/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/Exceptions.kt:23)
      	at io.realm.mongodb.AppException#<init>(/Users/realm/workspace-realm-kotlin/releases/packages/cinterop/src/commonMain/kotlin/io/realm/mongodb/AppException.kt:21)
      	at io.realm.internal.interop.RealmInterop.handleAppCallback#internal(/Users/realm/workspace-realm-kotlin/releases/packages/cinterop/src/darwin/kotlin/io/realm/internal/interop/RealmInterop.kt:1309)
      	at io.realm.internal.interop.RealmInterop.realm_app_log_in_with_credentials$lambda-11#internal(/Users/realm/workspace-realm-kotlin/releases/packages/cinterop/src/darwin/kotlin/io/realm/internal/interop/RealmInterop.kt:953)
      	at <global>._696f2e7265616c6d2e6b6f746c696e3a63696e7465726f70_knbridge296(/Users/realm/workspace-realm-kotlin/releases/packages/cinterop/src/darwin/kotlin/io/realm/internal/interop/RealmInterop.kt:954)
      	at <global>._ZNSt3__110__function6__funcIZN5realm5c_apiL13make_callbackEPFvPvP10realm_userPK15realm_app_errorES4_PFvS4_EEUlNS_10shared_ptrINS2_8SyncUserEEENS2_4util8OptionalINS2_3app8AppErrorEEEE_NS_9allocatorISM_EEFvSG_SL_EEclEOSG_OSL_(Unknown Source)
      	at <global>._ZNSt3__110__function6__funcIZN5realm3app3App23log_in_with_credentialsERKNS3_14AppCredentialsENS_10shared_ptrINS2_8SyncUserEEENS_8functionIFvSA_NS2_4util8OptionalINS3_8AppErrorEEEEEEE4$_14NS_9allocatorISI_EEFvNS3_8ResponseEEEclEOSL_(Unknown Source)
      	at <global>._ZNSt3__110__function6__funcIZN5realm3app3App10do_requestENS3_7RequestENS_8functionIFvNS3_8ResponseEEEEE4$_19NS_9allocatorISA_EEFvNS2_4util8OptionalINS3_8AppErrorEEENSE_IS7_EEEEclEOSG_OSH_(Unknown Source)
      	at <global>._ZNSt3__110__function6__funcIZN5realm3app3App17init_app_metadataENS_8functionIFvNS2_4util8OptionalINS3_8AppErrorEEENS7_INS3_8ResponseEEEEEEE4$_18NS_9allocatorISE_EEFvSA_EEclEOSA_(Unknown Source)
      	at <global>.realm_http_transport_complete_request(Unknown Source)
      	at io.realm.internal.interop.RealmInterop.<init>$lambda-0$<anonymous>_19_24#internal(/Users/teamcity1/teamcity_work/6326934d18cfe24e/kotlin/kotlin-native/Interop/Runtime/src/main/kotlin/kotlinx/cinterop/Utils.kt:636)
      	at io.realm.internal.interop.RealmInterop.$<init>$lambda-0$<anonymous>_19_24$FUNCTION_REFERENCE$352.response#internal(/Users/realm/workspace-realm-kotlin/releases/packages/cinterop/src/darwin/kotlin/io/realm/internal/interop/RealmInterop.kt:1365)
      	at io.realm.mongodb.internal.KtorNetworkTransport.$sendRequest$lambda-2COROUTINE$55.invokeSuspend#internal(/Users/realm/workspace-realm-kotlin/releases/packages/library-sync/src/commonMain/kotlin/io/realm/mongodb/internal/KtorNetworkTransport.kt:132)
      	at kotlin.coroutines.native.internal.BaseContinuationImpl#resumeWith(/Users/teamcity1/teamcity_work/6326934d18cfe24e/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/coroutines/ContinuationImpl.kt:30)
      	at io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith#internal(/Users/administrator/Documents/agent/work/8d547b974a7be21f/ktor-utils/common/src/io/ktor/util/pipeline/SuspendFunctionGun.kt:193)
      	at io.ktor.util.pipeline.SuspendFunctionGun.object-1.resumeWith#internal(/Users/administrator/Documents/agent/work/8d547b974a7be21f/ktor-utils/common/src/io/ktor/util/pipeline/SuspendFunctionGun.kt:89)
      	at kotlin.coroutines.native.internal.BaseContinuationImpl#resumeWith(/Users/teamcity1/teamcity_work/6326934d18cfe24e/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/coroutines/ContinuationImpl.kt:43)
      	at io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith#internal(/Users/administrator/Documents/agent/work/8d547b974a7be21f/ktor-utils/common/src/io/ktor/util/pipeline/SuspendFunctionGun.kt:193)
      	at io.ktor.util.pipeline.SuspendFunctionGun.object-1.resumeWith#internal(/Users/administrator/Documents/agent/work/8d547b974a7be21f/ktor-utils/common/src/io/ktor/util/pipeline/SuspendFunctionGun.kt:89)
      	at kotlin.coroutines.native.internal.BaseContinuationImpl#resumeWith(/Users/teamcity1/teamcity_work/6326934d18cfe24e/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/coroutines/ContinuationImpl.kt:43)
      	at io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith#internal(/Users/administrator/Documents/agent/work/8d547b974a7be21f/ktor-utils/common/src/io/ktor/util/pipeline/SuspendFunctionGun.kt:193)
      	at io.ktor.util.pipeline.SuspendFunctionGun.object-1.resumeWith#internal(/Users/administrator/Documents/agent/work/8d547b974a7be21f/ktor-utils/common/src/io/ktor/util/pipeline/SuspendFunctionGun.kt:89)
      	at kotlin.coroutines.native.internal.BaseContinuationImpl#resumeWith(/Users/teamcity1/teamcity_work/6326934d18cfe24e/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/coroutines/ContinuationImpl.kt:43)
      	at io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith#internal(/Users/administrator/Documents/agent/work/8d547b974a7be21f/ktor-utils/common/src/io/ktor/util/pipeline/SuspendFunctionGun.kt:193)
      	at io.ktor.util.pipeline.SuspendFunctionGun.object-1.resumeWith#internal(/Users/administrator/Documents/agent/work/8d547b974a7be21f/ktor-utils/common/src/io/ktor/util/pipeline/SuspendFunctionGun.kt:89)
      	at kotlin.coroutines.native.internal.BaseContinuationImpl#resumeWith(/Users/teamcity1/teamcity_work/6326934d18cfe24e/kotlin/kotlin-native/runtime/src/main/kotlin/kotlin/coroutines/ContinuationImpl.kt:43)
      	at io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith#internal(/Users/administrator/Documents/agent/work/8d547b974a7be21f/ktor-utils/common/src/io/ktor/util/pipeline/SuspendFunctionGun.kt:193)
      	at io.ktor.util.pipeline.SuspendFunctionGun.object-1.resumeWith#internal(/Users/administrator/Documents/agent/work/8d547b974a7be21f/ktor-utils/common/src/io/ktor/util/pipeline/SuspendFunctionGun.kt:89)
      showsClassesWhenCreated[ios]
      

      Here is my setup:

      val appId: String = "<app-id>"
          val partitionValue: String = "public"
          val app: App = App.create(appId)
          val realm: Realm
      
          init {
              realm = runBlocking {
                  val user = app.login(Credentials.anonymous())
                  val config = SyncConfiguration.Builder(
                      user = user,
                      partitionValue = partitionValue,
                      schema = setOf(
                          RealmRace::class,
                          RealmTheme::class,
                          RealmCharacterClass::class
                      )
                  ).build()
      
                  Realm.open(config)
              }
      }
      

            Assignee:
            nabil.hachicha@mongodb.com Nabil Hachicha
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: