기본 콘텐츠로 건너뛰기

gsjava No subject alternative names matching IP address

No subject alternative names matching IP address 

// ssl security Exception 방지
	public void disableSslVerification(){
		// TODO Auto-generated method stub
		try
	    {
	        // Create a trust manager that does not validate certificate chains
	        TrustManager[] trustAllCerts = new TrustManager[] {new X509TrustManager() {
	            public java.security.cert.X509Certificate[] getAcceptedIssuers() {
	                return null;
	            }
	            public void checkClientTrusted(X509Certificate[] certs, String authType){
	            }
	            public void checkServerTrusted(X509Certificate[] certs, String authType){
	            }
	        }
	        };
	
	        // Install the all-trusting trust manager
	        SSLContext sc = SSLContext.getInstance("SSL");
	        sc.init(null, trustAllCerts, new java.security.SecureRandom());
	        HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
	
	        // Create all-trusting host name verifier
	        HostnameVerifier allHostsValid = new HostnameVerifier() {
	            public boolean verify(String hostname, SSLSession session){
	                return true;
	            }
	        };
	
	        // Install the all-trusting host verifier
	        HttpsURLConnection.setDefaultHostnameVerifier(allHostsValid);
	    } catch (NoSuchAlgorithmException e) {
	        e.printStackTrace();
	    } catch (KeyManagementException e) {
	        e.printStackTrace();
	    }
	}

If you google for the above exception, most of the results will suggest you to write a custom HostNameVerifier which will always return true like this;

/**
 * Host name verifier that does not perform nay checks.
 */
private static class NullHostnameVerifier implements HostnameVerifier {
    public boolean verify(String hostname, SSLSession session) {
        return true;
    }
}

... and apply this disabled host name checker for current connection only;

/* disabling hostnamechecking only for current connection */
URL url = new URL("https://localhost:9443/soap_rpc");
HttpsURLConnection connection = (HttpsURLConnection)url.openConnection();
connection.setHostnameVerifier(new NullHostNameVerifier());

댓글

이 블로그의 인기 게시물

UltraEdit Professional Version 18.20.0.1014 라이센스 키 넣기

Step 1: unpack rar archive      Step 2: run the setup   Step 3: Use the given keygen to activate    Add the line   127.0.0.1 licensing.ultraedit.com         to your %WINDOWS%\system32\drivers\etc\hosts file                 Enter any data for license-id and password (license-id must be a         number)                 Choose Offline activation and generate corresponding activation         codes for your user codes   Step 4: Enjoy and Support Developers, Buy It, They Deserved It!

gsjava WeGuardia™ SSLplus 특징(퓨쳐시스템 => 퓨쳐텍정보통신으로 이관)

☎ 문의 :  010-3240-0041 김성은 소장 01.   웹기반   인터페이스   제공 ……. –  웹기반   인터관리   및   사용   편리성을   제공 ……. –  실시간 터널수, 실시간 위반 사용자 등   복잡   정교한   정보   표시를   구현 02.   사용자를   위한   다양한   클라이언트   제공 ……. –  윈도우 , IOS,MAC, 안드로이드   및   리눅스   클라이언트   제공 ……. –  항시   암호화된   네트워크   연결성 ,  보안성   및   단말  Compliance  등  NAC  기능 03.   사용자   친화적   앱   목록 ……. – OS 별 앱 목록을 등록후 사용 가능 ……. –  사용자는   접속   정보   기억   불필요 ,  접속   후 ,  앱   목록에서   원하는   앱을   선택하여   클릭 ……. –  기업   필수   앱   배포   가능 04.   효율적인  VPN Tunneling ……. – Non Split Tunneling 과  Split Tunneling 을   지원 ,  업무   트래픽과   일반   인터넷   트래픽   분리   처리   가능 ……. – WeGuardia™SSLplus  보안설정을 ...