Skip to content

Commit aff250d

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 945f5e2 + bdc2018 commit aff250d

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import java.util.HashSet;
3939
import java.util.LinkedList;
4040
import java.util.List;
41+
import java.util.Locale;
4142
import java.util.Map;
4243
import java.util.Set;
4344
import java.util.concurrent.ConcurrentHashMap;
@@ -567,7 +568,7 @@ private List<BasicNameValuePair> getParamsList(String key, Object value) {
567568
if (nestedKey instanceof String) {
568569
Object nestedValue = map.get(nestedKey);
569570
if (nestedValue != null) {
570-
params.addAll(getParamsList(key == null ? (String) nestedKey : String.format("%s[%s]", key, nestedKey),
571+
params.addAll(getParamsList(key == null ? (String) nestedKey : String.format(Locale.US, "%s[%s]", key, nestedKey),
571572
nestedValue));
572573
}
573574
}
@@ -576,13 +577,13 @@ private List<BasicNameValuePair> getParamsList(String key, Object value) {
576577
List list = (List) value;
577578
int listSize = list.size();
578579
for (int nestedValueIndex = 0; nestedValueIndex < listSize; nestedValueIndex++) {
579-
params.addAll(getParamsList(String.format("%s[%d]", key, nestedValueIndex), list.get(nestedValueIndex)));
580+
params.addAll(getParamsList(String.format(Locale.US, "%s[%d]", key, nestedValueIndex), list.get(nestedValueIndex)));
580581
}
581582
} else if (value instanceof Object[]) {
582583
Object[] array = (Object[]) value;
583584
int arrayLength = array.length;
584585
for (int nestedValueIndex = 0; nestedValueIndex < arrayLength; nestedValueIndex++) {
585-
params.addAll(getParamsList(String.format("%s[%d]", key, nestedValueIndex), array[nestedValueIndex]));
586+
params.addAll(getParamsList(String.format(Locale.US, "%s[%d]", key, nestedValueIndex), array[nestedValueIndex]));
586587
}
587588
} else if (value instanceof Set) {
588589
Set set = (Set) value;

sample/src/main/java/com/loopj/android/http/sample/util/SecureSocketFactory.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import java.security.cert.X509Certificate;
4646

4747
import javax.net.ssl.SSLContext;
48+
import javax.net.ssl.SSLSocket;
4849
import javax.net.ssl.TrustManager;
4950
import javax.net.ssl.X509TrustManager;
5051

@@ -166,7 +167,12 @@ public Socket createSocket(Socket socket, String host, int port, boolean autoClo
166167
throws IOException {
167168

168169
injectHostname(socket, host);
169-
return sslCtx.getSocketFactory().createSocket(socket, host, port, autoClose);
170+
Socket sslSocket = sslCtx.getSocketFactory().createSocket(socket, host, port, autoClose);
171+
172+
// throw an exception if the hostname does not match the certificate
173+
getHostnameVerifier().verify(host, (SSLSocket) sslSocket);
174+
175+
return sslSocket;
170176
}
171177

172178
@Override

0 commit comments

Comments
 (0)