我提一下我迄今试图开始我的问题:SSL钢钉使用谷歌凌空
我没有在我的应用程序的证书,我使用SHA256键而已,大部分互联网上的答案需要物理证书在应用程序中加载它在密钥库中,我没有。
我收到以下错误:
javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
1)TrustKit它不需要编译SDK 24及以上,但我有23和许多支持库都与SDK 23同步,所以我不能改变这一切他们,它可能会在某个时候崩溃我的应用程序。
2)CWAC-NetSecurity我已经在我的代码中实现了这个功能,但没有使用Android N安全设置,我也遵循git页面给出的指令,但无法将sslSocketfactory从它传递给Volley,它有OkHTTP示例。所以它也给出了上述错误。
我已经用OKHttp的CertificatePinner试过了,它也不适合我。同样的错误。我也尝试将hostNameVerifier和sslSocketFactory传递给HttpsUrlConnection,但是发生同样的错误。
JsonObjectRequestSolaire jsonRequest = new JsonObjectRequestSolaire(method, URL, object, headers, responseListener, errorListener);
RetryPolicy policy = new DefaultRetryPolicy(TIMEOUT, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);
jsonRequest.setRetryPolicy(policy);
jsonRequest.setShouldCache(false);
OkHttpClient okHttpClient = new OkHttpClient.Builder()
.certificatePinner(new CertificatePinner.Builder()
.add("my_domain", "sha256/shaKey")//example.com
.add("my_domain", "sha256/shaKey")//also tried *.example.com
.build())
.build();
//HttpsURLConnection.setDefaultHostnameVerifier(okHttpClient.hostnameVerifier());
//HttpsURLConnection.setDefaultSSLSocketFactory(okHttpClient.sslSocketFactory());
RequestQueue requestQueue = Volley.newRequestQueue(activity.getApplicationContext(), new HurlStack(null, okHttpClient.sslSocketFactory()));
requestQueue.add(jsonRequest);
通过使用trustKit我们的iOS人员实施,它是为他工作。
在此先感谢。
请在这里分享您的宝贵意见,以便我能理解这个SSL固定概念。
是所用的服务器证书是否有效?固定意味着定期检查证书+固定根,中间或离开证书。顺便说一句:如果你有sha256散列和域名,你可以简单地从服务器上下载证书来验证它是否是正确的。 – Robert
也请查看[此链接](http://blog.ostorlab.co/2016/05/ssl-pinning-in-android-networking.html)。 –
也检查[this](https://developer.android.com/training/articles/security-ssl.html#CommonProblems),可能是CA的问题。 –