Crash using okta kotlin sdk

I’m having a crash inside the sdk when trying to run okta login with our custom ui

these are the dependencies:

api("com.okta.kotlin:auth-foundation:2.0.2") {
        exclude(group = "org.bouncycastle")
    }
    implementation("com.okta.kotlin:oauth2:2.0.2") {
        exclude(group = "org.bouncycastle")
    }
    implementation("com.okta.authn.sdk:okta-authn-sdk-api:3.0.0") {
        exclude(group = "org.bouncycastle")
    }
    runtimeOnly("com.okta.authn.sdk:okta-authn-sdk-impl:3.0.0") {
        exclude(group = "com.okta.sdk", module = "okta-sdk-httpclient")
        exclude(group = "org.bouncycastle")
    }
    runtimeOnly("com.okta.commons:okta-http-httpclient:2.0.1") {
        exclude(group = "org.bouncycastle")
    }

and this is the code executing:

val orgUrl = OktaParams.oktaIssuer.toHttpUrl().newBuilder()
                    .encodedPath("/")
                    .build().toString()
                val authenticationClient = AuthenticationClients.builder().setOrgUrl(orgUrl).build()
                authenticationClient?.authenticate(
                    email,
                    pass.toCharArray(),
                    null,
                    object : AuthenticationStateHandlerAdapter() {
                        override fun handleUnknown(unknownResponse: AuthenticationResponse) {
                            _errorMessage.update {
                                unknownResponse.factorResultMessage
                            }
                            restorePreRequestState()
                        }

                        override fun handleSuccess(successResponse: AuthenticationResponse) {
                            completeLoginWithSessionToken(successResponse.sessionToken)
                        }
                    }
                )

on the line:

                val authenticationClient = AuthenticationClients.builder().setOrgUrl(orgUrl).build()

I’m getting this crash:

java.lang.NoSuchFieldError: No static field INSTANCE of type Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier; in class Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier; or its superclasses (declaration of 'org.apache.http.conn.ssl.AllowAllHostnameVerifier' appears in /system/framework/framework.jar!classes4.dex)
                 	at org.apache.http.conn.ssl.SSLConnectionSocketFactory.<clinit>(SSLConnectionSocketFactory.java:151)
                 	at org.apache.http.conn.ssl.SSLConnectionSocketFactory.getSocketFactory(Unknown Source:0)
                 	at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.getDefaultRegistry(PoolingHttpClientConnectionManager.java:116)
                 	at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.<init>(PoolingHttpClientConnectionManager.java:127)
                 	at com.okta.commons.http.httpclient.HttpClientRequestExecutor.<init>(HttpClientRequestExecutor.java:111)
                 	at com.okta.commons.http.httpclient.HttpClientRequestExecutorFactory.create(HttpClientRequestExecutorFactory.java:32)
                 	at com.okta.sdk.impl.client.BaseClient.createRequestExecutor(BaseClient.java:80)
                 	at com.okta.sdk.impl.client.BaseClient.<init>(BaseClient.java:50)
                 	at com.okta.sdk.impl.client.BaseClient.<init>(BaseClient.java:45)
                 	at com.okta.authn.sdk.impl.client.DefaultAuthenticationClient.<init>(DefaultAuthenticationClient.java:70)
                 	at com.okta.authn.sdk.impl.client.DefaultAuthenticationClientBuilder.build(DefaultAuthenticationClientBuilder.java:212)

This error is present also in the okta-mobile-kotlin sample app also

Hi @jaime.gomez,

This is not an issue that’s specific to the Kotlin SDK, but to the version of “htmlunit” that’s being used as described here.

I would suggest either rolling that dependency back or upgrading it to the newest version to see if it resolve the issue. You can also put in an Issue to get this addressed.