보안상의 이슈로 TLS 1.0 / 1.1 을 점점 더 지원하지 않는 서버가 많아지고 있습니다.
이때, TLS 1.2만을 지원하는 서버에는 Android 4.4가 접속하지 못하는 경우가 발생하고 있습니다. (SSL handshake aborted)
아래와 같이, Android 4.4도 스팩상으로는 TLS 1.2를 지원하지만 버그로 인해 SSLHandshakeException이 발생합니다.
(자세한 내용은 아래 Reference를 참고해 주세요)
그동안은 SSLSocketFactory를 상속받아 TLS1.2를 활성화한 SSLSocketFactory를 사용했지만 Chipher Suites의 종류에 따라 코딩하기가 번거로웠습니다.
그런데 Google에서 보안 공급자를 제공하는 방식으로 쉽게 해결이 가능하여 포스팅합니다.
위의 설명을 보면 TLS라는 단어는 나오지 않습니다만! 됩니다. 되요!
아래 코드를 앱 실행시에 호출해 주시면 됩니다. 간단하죠? :)
import com.google.android.gms.common.GooglePlayServicesNotAvailableException;
import com.google.android.gms.common.GooglePlayServicesRepairableException;
import com.google.android.gms.security.ProviderInstaller;
try {
ProviderInstaller.installIfNeeded(getApplicationContext());
/**
* https://developer.android.com/training/articles/security-gms-provider.html
* this can take anywhere from 30-50 milliseconds (on more recent devices) to 350 ms (on older devices)
* keywords: installIfNeeded(), installIfNeededAsync()
*
* Once the Provider is updated, all calls to security APIs (including SSL APIs) are routed through it.
* (However, this does not apply to android.net.SSLCertificateSocketFactory,
* which remains vulnerable to such exploits as CVE-2014-0224.)
*
*/
} catch (GooglePlayServicesRepairableException e) {
e.printStackTrace();
} catch (GooglePlayServicesNotAvailableException e) {
e.printStackTrace();
}
Reference
- How to enable TLS 1.2 support in an Android application (running on Android 4.1 JB)
- android deveploter - SSL 악용을 차단하기 위해 보안 제공자 업데이트
- google apis for android - ProviderInstaller
- Android에서 TLS 1.2 사용하기 4.4
- Enable TLS 1.2 in Android 4.4
- GitHub Gist - Sample for how to use the Google Play Services dynamic security provider to keep the SSL library that the app will use to up date.
반응형
'프로그래밍 > Android' 카테고리의 다른 글
[bug fix] Expected @HiltAndroidApp to have a value. Did you forget to apply the Gradle Plugin? 해결하기 (0) | 2021.06.30 |
---|---|
Heads Up Notification를 표시하는 방법 (Android P 와 이전 버전의 차이점) (0) | 2019.01.28 |
Andorid 앱 푸시 알림이 꺼져 있는지 확인하는 방법 (0) | 2019.01.24 |
Android P 에서 Heads Up Notification 표시하는 방법. (0) | 2019.01.23 |
Firebase Cloud Messaging(FCM) 제대로 알고 사용하자! (0) | 2019.01.23 |