You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have set up RESTMockServer using https by calling the following function in the Runner for our Android instrumented tests:
privatefunprovisionMockServer() {
RESTMockServer.enableLogging(LaundrappRESTMockLogger())
val builder =RESTMockOptions.Builder().useHttps(true).build()
RESTMockServerStarter.startSync(AndroidAssetsFileParser(context), AndroidLogger(), builder)
}
We also then pass the SSLSocketFactory into our production app as shown in the example app. Using this method works well with Android versions up to Android Oreo (API 27) but running tests fails with the following exception on an emulator running API 28:
E/AndroidRuntime: FATAL EXCEPTION: pool-4-thread-1
Process: com.company.ourapp, PID: 6114
java.lang.AssertionError: java.security.NoSuchAlgorithmException: The BC provider no longer provides an implementation for KeyPairGenerator.RSA. Please see https://android-developers.googleblog.com/2018/03/cryptography-changes-in-android-p.html for more details.
at okhttp3.tls.HeldCertificate$Builder.generateKeyPair(HeldCertificate.java:429)
at okhttp3.tls.HeldCertificate$Builder.build(HeldCertificate.java:353)
at io.appflate.restmock.SslUtils.localhost(SslUtils.java:44)
at io.appflate.restmock.RESTMockServer.setUpHttps(RESTMockServer.java:91)
at io.appflate.restmock.RESTMockServer.init(RESTMockServer.java:74)
at io.appflate.restmock.RESTMockServerStarter$1.run(RESTMockServerStarter.java:56)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
Caused by: java.security.NoSuchAlgorithmException: The BC provider no longer provides an implementation for KeyPairGenerator.RSA. Please see https://android-developers.googleblog.com/2018/03/cryptography-changes-in-android-p.html for more details.
at sun.security.jca.Providers.checkBouncyCastleDeprecation(Providers.java:563)
at sun.security.jca.Providers.checkBouncyCastleDeprecation(Providers.java:330)
at java.security.KeyPairGenerator.getInstance(KeyPairGenerator.java:303)
at okhttp3.tls.HeldCertificate$Builder.generateKeyPair(HeldCertificate.java:425)
at okhttp3.tls.HeldCertificate$Builder.build(HeldCertificate.java:353)
at io.appflate.restmock.SslUtils.localhost(SslUtils.java:44)
at io.appflate.restmock.RESTMockServer.setUpHttps(RESTMockServer.java:91)
at io.appflate.restmock.RESTMockServer.init(RESTMockServer.java:74)
at io.appflate.restmock.RESTMockServerStarter$1.run(RESTMockServerStarter.java:56)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
Running the production app works fine so this has to be an issue with our testing setup - most likely RESTMockServer's usage of OkHttp looking at the stacktrace.
The text was updated successfully, but these errors were encountered:
LUwaisA
changed the title
Version 0.3.2 needs OkHttp update to work with API Level 28
Version 0.3.2 with HTTPS throws exception on API Level 28
Feb 10, 2019
configurations.all {
resolutionStrategy {
force "com.squareup.okhttp3:okhttp:3.13.1"
force "com.squareup.okhttp3:okhttp-tls:3.13.1"
force "com.squareup.okhttp3:mockwebserver:3.13.1"
force "com.squareup.okhttp3:logging-interceptor:3.13.1"
}
}
to our app's build.gradle seems to avoid the issue above on API Level 28 (Android P) but runs into other issues because other dependencies are not expecting these forced dependencies. Regardless of that - it looks like just updating to okhttp 3.13.1 would solve this issue. Hopefully this isn't too much of a change.
We have set up RESTMockServer using https by calling the following function in the Runner for our Android instrumented tests:
We also then pass the SSLSocketFactory into our production app as shown in the example app. Using this method works well with Android versions up to Android Oreo (API 27) but running tests fails with the following exception on an emulator running API 28:
Running the production app works fine so this has to be an issue with our testing setup - most likely RESTMockServer's usage of OkHttp looking at the stacktrace.
The text was updated successfully, but these errors were encountered: