在Android應用程序中,我從https網址獲取內容;爲了避免SSL證書驗證錯誤,我將SSL公鑰添加到我的密鑰庫中,然後該密鑰庫駐留在應用程序的res/raw文件夾中。 按照http://blog.crazybob.org/2010/02/android-trusting-ssl-certificates.html的說明操作,目前爲止所有工作都正常。Proguard導致Android上的SSL密鑰庫出現問題
..直到我激活Proguard和混淆。隨着Proguard激活,我得到以下錯誤,
ERROR/Login(4401): Could not login.
javax.net.ssl.SSLException: hostname in certificate didn't match: <store.mydomain.com/185.165.192.15> != <store.mydomain.com> OR <store.mydomain.com>
at xyz.fd.a(Unknown Source)
我不太明白。爲什麼URL的標識改變的方式是它也將/<ipAddress>
與域名一起取得,而它在沒有Proguard混淆的情況下正常工作。
由於HttpClient的用於讀取的HTTPS內容,我用源在MyHttpClient在: http://blog.crazybob.org/2010/02/android-trusting-ssl-certificates.html
proguard.cfg:
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep class * extends DefaultHttpClient
-ignorewarnings
-repackageclasses 'xyz'
-allowaccessmodification
-keepclasseswithmembernames class * {
native <methods>;
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
更新:
而且消除-repackageclasses「XYZ '和-allowaccessmodification沒有區別,同樣的錯誤。