이미지 경로를 통해 이미지를 불러와서 로컬에 저장하는 부분에서
Caused by: javax.net.ssl.SSLException: Received fatal alert: protocol_version
SSLExcpetion이 발생하는 경우가 생김
Java 버전별로 defalut로 설정되는 프로토콜 버전이 다른데
Java 7이용하다보니 TLSv1 이상으로 된 페이지의 이미지를 불러오지 못함
| Java Version | SSL/TLS Default | Other Supported Versions |
|---|---|---|
| Java 6 | TLS 1.0 | TLS 1.1 (update 111 and later), SSLv3.0* |
| Java 7 | TLS 1.0 | TLS 1.2, TLS 1.1, SSLv3.0* |
| Java 8 | TLS 1.2 | TLS 1.1, TLS 1.0, SSLv3.0* |
* SSLv3 support disabled in January, 2015 patch releases
※ 참고 url : http://www.ateam-oracle.com/tls-and-java/
Solution 1. jvm옵션을 지정해 주는 경우
-Dhttps.protocols=TLSv1,TLSv1.1,TLSv1.2
를 추가해서 jvm의 기본 https protocols의 설정을 변경
Solution 2. System.setProperty()를 이용
System.setProperty를 이용해 https protocols의 설정을 강제해 주는 방법
예제 코드는 아래 첨부
import java.awt.image.BufferedImage;
import java.net.URL;
import javax.imageio.ImageIO;
public class UrlTest {
public static void main(String[] args) {
URL url = null;
String imageUri = "";
BufferedImage image = null;
try{
imageUri = "https://이미지 경로";
System.setProperty("https.protocols", "TLSv1,TLSv1.1,TLSv1.2");
url = new URL(imageUri);
image = ImageIO.read( url );
}catch(Exception e){
e.printStackTrace();
}
}
}
참고
1) https://sarc.io/index.php/java/1306-ssl-tls-and-java-support-default
2) http://freestrokes.tistory.com/68
'Coding > Servlet & JSP' 카테고리의 다른 글
| encoding 관련 (0) | 2018.01.15 |
|---|---|
| 주사위 돌리기 (0) | 2018.01.10 |
| 별찍기 (0) | 2018.01.10 |
| Tomcat v8.5 설치 (0) | 2018.01.10 |