Parcourir la source

Apex Mobile
A180318

Ray Zhang il y a 8 ans
Parent
commit
f2408c67de

+ 2 - 2
Apex Mobile/app/src/main/AndroidManifest.xml

@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="com.usai.apex"
-    android:versionCode="8"
-    android:versionName="A180313"> <!-- Copied from Google Maps Library/AndroidManifest.xml. -->
+    android:versionCode="11"
+    android:versionName="A180318"> <!-- Copied from Google Maps Library/AndroidManifest.xml. -->
     <uses-sdk
         android:minSdkVersion="14"
         android:targetSdkVersion="18" />

+ 19 - 6
Apex Mobile/app/src/main/java/com/usai/util/Network.java

@@ -1503,12 +1503,24 @@ public class Network
 				{
 				}
 
+				//				@Override
+//				public void checkServerTrusted(
+//						java.security.cert.X509Certificate[] chain,
+//						String authType)
+//						throws java.security.cert.CertificateException
+//				{
+//				}
 				@Override
-				public void checkServerTrusted(
-						java.security.cert.X509Certificate[] chain,
-						String authType)
-						throws java.security.cert.CertificateException
-				{
+				public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) throws java.security.cert.CertificateException {
+					try {
+						chain[0].checkValidity();
+					} catch (java.security.cert.CertificateExpiredException e) {
+						// Logger.e(TAG, "CertificateExpiredException");
+						throw new java.security.cert.CertificateException("CertificateExpiredException");
+					} catch (java.security.cert.CertificateNotYetValidException e) {
+						//Logger.e(TAG, "CertificateNotYetValidException");
+						throw new java.security.cert.CertificateException("CertificateNotYetValidException");
+					}
 				}
 			};
 			sslContext.init(null, new TrustManager[] { tm }, null);
@@ -1516,7 +1528,8 @@ public class Network
 
 		@Override
 		public Socket createSocket(Socket socket, String host, int port,
-								   boolean autoClose) throws IOException {
+								   boolean autoClose) throws IOException, UnknownHostException
+		{
 			return sslContext.getSocketFactory().createSocket(socket, host,
 					port, autoClose);
 		}