Skip to content

Commit 1b29bb9

Browse files
author
Peter Joseph Olamit
authored
Tag/1.0.0 beta06 (#92)
- Security updates
1 parent c4c1148 commit 1b29bb9

File tree

6 files changed

+88
-3
lines changed

6 files changed

+88
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
Changelog
22
=========
33

4+
[1.0.0-beta06](https://github.com/hyperwallet/hyperwallet-android-sdk/releases/tag/1.0.0-beta06)
5+
-------------------
6+
* Security updates
7+
48
[1.0.0-beta05](https://github.com/hyperwallet/hyperwallet-android-sdk/releases/tag/1.0.0-beta05)
59
-------------------
610
* Added support to list User Balance

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ We also provide an out-of-the-box [Hyperwallet Android UI SDK](https://github.c
2121
To install Hyperwallet Core SDK, you just need to add the dependency into your build.gradle file in Android Studio (or Gradle). For example:
2222

2323
```bash
24-
api 'com.hyperwallet.android:core-sdk:1.0.0-beta05'
24+
api 'com.hyperwallet.android:core-sdk:1.0.0-beta06'
2525
```
2626

2727
## Initialization

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ allprojects {
2121
mavenLocal()
2222
}
2323

24-
project.version = "1.0.0-beta05"
24+
project.version = "1.0.0-beta06"
2525
}
2626

2727
task clean(type: Delete) {

core/config/jacoco-settings.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ def fileFilter = ['**/R.class',
2727
'**/Manifest*.*',
2828
'android/**/*.*',
2929
'**/com/hyperwallet/android/Hyperwallet.class',
30-
'**/com/hyperwallet/android/Hyperwallet$*.class']
30+
'**/com/hyperwallet/android/Hyperwallet$*.class',
31+
'**/com/hyperwallet/android/util/Tls12SocketFactory*']
3132
def debugClassPaths = [
3233
'**/intermediates/javac/debug/*/classes/**'
3334
]

core/src/main/java/com/hyperwallet/android/util/HttpClient.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
import java.util.HashMap;
3535
import java.util.Map;
3636

37+
import javax.net.ssl.HttpsURLConnection;
38+
3739
/**
3840
* {@code HttpClient} object represents routine on making HTTP calls to Hyperwallet Platforms' API
3941
*/
@@ -242,6 +244,12 @@ public HttpClient build() throws IOException, URISyntaxException, HyperwalletInv
242244

243245
url.append(buildQuery());
244246

247+
try {
248+
HttpsURLConnection.setDefaultSSLSocketFactory(new Tls12SocketFactory());
249+
} catch (Exception e) {
250+
e.printStackTrace();
251+
}
252+
245253
URI uri = new URI(url.toString());
246254
mHttpUrlConnection = (HttpURLConnection) uri.toURL().openConnection();
247255
mHttpUrlConnection.setConnectTimeout(mConnectTimeout);
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
package com.hyperwallet.android.util;
2+
3+
import java.io.IOException;
4+
import java.net.InetAddress;
5+
import java.net.Socket;
6+
import java.net.UnknownHostException;
7+
import java.security.KeyManagementException;
8+
import java.security.NoSuchAlgorithmException;
9+
10+
import javax.net.ssl.SSLContext;
11+
import javax.net.ssl.SSLSocket;
12+
import javax.net.ssl.SSLSocketFactory;
13+
14+
public class Tls12SocketFactory extends SSLSocketFactory {
15+
16+
private SSLSocketFactory internalSSLSocketFactory;
17+
18+
public Tls12SocketFactory() throws KeyManagementException, NoSuchAlgorithmException {
19+
SSLContext context = SSLContext.getInstance("TLS");
20+
context.init(null, null, null);
21+
internalSSLSocketFactory = context.getSocketFactory();
22+
}
23+
24+
@Override
25+
public String[] getDefaultCipherSuites() {
26+
return internalSSLSocketFactory.getDefaultCipherSuites();
27+
}
28+
29+
@Override
30+
public String[] getSupportedCipherSuites() {
31+
return internalSSLSocketFactory.getSupportedCipherSuites();
32+
}
33+
34+
@Override
35+
public Socket createSocket() throws IOException {
36+
return patch(internalSSLSocketFactory.createSocket());
37+
}
38+
39+
@Override
40+
public Socket createSocket(Socket s, String host, int port, boolean autoClose) throws IOException {
41+
return patch(internalSSLSocketFactory.createSocket(s, host, port, autoClose));
42+
}
43+
44+
@Override
45+
public Socket createSocket(String host, int port) throws IOException {
46+
return patch(internalSSLSocketFactory.createSocket(host, port));
47+
}
48+
49+
@Override
50+
public Socket createSocket(String host, int port, InetAddress localHost, int localPort)
51+
throws IOException {
52+
return patch(internalSSLSocketFactory.createSocket(host, port, localHost, localPort));
53+
}
54+
55+
@Override
56+
public Socket createSocket(InetAddress host, int port) throws IOException {
57+
return patch(internalSSLSocketFactory.createSocket(host, port));
58+
}
59+
60+
@Override
61+
public Socket createSocket(InetAddress address, int port, InetAddress localAddress, int localPort)
62+
throws IOException {
63+
return patch(internalSSLSocketFactory.createSocket(address, port, localAddress, localPort));
64+
}
65+
66+
private Socket patch(Socket socket) {
67+
if ((socket instanceof SSLSocket)) {
68+
((SSLSocket) socket).setEnabledProtocols(new String[]{"TLSv1.2"});
69+
}
70+
return socket;
71+
}
72+
}

0 commit comments

Comments
 (0)