在Android应用中,我从https网址获取内容;为了避免SSL证书验证错误,我将SSL公钥添加到我的密钥库,然后密钥库驻留在应用程序的res / raw文件夹中。 遵循http://blog.crazybob.org/2010/02/android-trusting-ssl-certificates.html上的说明,到目前为止一切正常。
..直到我激活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的idenfitication会以一种方式改变,它也会将/<ipAddress>
与域名一起提取,而它在没有Proguard混淆的情况下工作正常。
作为用于获取https内容的httpClient,我使用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并没有什么区别,同样的错误。
答案 0 :(得分:1)
我使用的是最新的httpclient 4.1.2。现在,当我切换回4.1.1时,问题就消失了。
另见:http://comments.gmane.org/gmane.comp.apache.httpclient.user/262