Skip to content

Commit 34a23f8

Browse files
committed
Fixing a security issue which is banned by google play.
1 parent f53deef commit 34a23f8

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

library/src/main/java/com/loopj/android/http/MySSLSocketFactory.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,19 @@ public MySSLSocketFactory(KeyStore truststore) throws NoSuchAlgorithmException,
7272

7373
X509TrustManager tm = new X509TrustManager() {
7474
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
75+
try {
76+
chain[0].checkValidity();
77+
} catch (Exception e) {
78+
throw new CertificateException("Certificate not valid or trusted.");
79+
}
7580
}
7681

7782
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
83+
try {
84+
chain[0].checkValidity();
85+
} catch (Exception e) {
86+
throw new CertificateException("Certificate not valid or trusted.");
87+
}
7888
}
7989

8090
public X509Certificate[] getAcceptedIssuers() {

0 commit comments

Comments
 (0)