|
|
@@ -15,6 +15,7 @@ public class HttpConnectionUtil {
|
|
|
private String connectUrl;
|
|
|
|
|
|
final static HostnameVerifier DO_NOT_VERIFY = new HostnameVerifier() {
|
|
|
+ @Override
|
|
|
public boolean verify(String hostname, SSLSession session) {
|
|
|
return true;
|
|
|
}
|
|
|
@@ -32,6 +33,7 @@ public class HttpConnectionUtil {
|
|
|
// System.setProperty("java.protocol.handler.pkgs", "javax.net.ssl");
|
|
|
trustAllHosts();
|
|
|
HostnameVerifier hv = new HostnameVerifier() {
|
|
|
+ @Override
|
|
|
public boolean verify(String urlHostName, SSLSession session) {
|
|
|
return urlHostName.equals(session.getPeerHost());
|
|
|
}
|
|
|
@@ -78,8 +80,9 @@ public class HttpConnectionUtil {
|
|
|
StringBuilder outBuf = new StringBuilder();
|
|
|
boolean isNotFirst = false;
|
|
|
for (Map.Entry<String, String> entry : params.entrySet()) {
|
|
|
- if (isNotFirst)
|
|
|
+ if (isNotFirst) {
|
|
|
outBuf.append('&');
|
|
|
+ }
|
|
|
isNotFirst = true;
|
|
|
outBuf
|
|
|
.append(entry.getKey())
|
|
|
@@ -119,8 +122,9 @@ public class HttpConnectionUtil {
|
|
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
|
int readLen;
|
|
|
byte[] tmpBuf = new byte[4096];
|
|
|
- while ((readLen = is.read(tmpBuf)) > 0)
|
|
|
+ while ((readLen = is.read(tmpBuf)) > 0) {
|
|
|
baos.write(tmpBuf, 0, readLen);
|
|
|
+ }
|
|
|
is.close();
|
|
|
return baos.toByteArray();
|
|
|
}
|
|
|
@@ -136,13 +140,14 @@ public class HttpConnectionUtil {
|
|
|
final String TAG = "trustAllHosts";
|
|
|
// Create a trust manager that does not validate certificate chains
|
|
|
TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() {
|
|
|
+ @Override
|
|
|
public X509Certificate[] getAcceptedIssuers() {
|
|
|
return new X509Certificate[]{};
|
|
|
}
|
|
|
-
|
|
|
+ @Override
|
|
|
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
|
|
|
}
|
|
|
-
|
|
|
+ @Override
|
|
|
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
|
|
|
}
|
|
|
}};
|