2011-10-27 4 views
1

Google 검색 어플라이언스를 관리하고 액세스 제어 목록 (ACL)을 수정하기위한 인증 키를 얻으려고했습니다. 내가 지시 here을 따랐지만 난 항상이 예외 얻을GSA API - 인증 토큰을 얻을 수 없습니다.

SocketAddress proxyAddress = new InetSocketAddress(PROXY_HOST,PROXY_PORT); 
    Proxy proxy = new Proxy(Proxy.Type.HTTP, proxyAddress); 
    URL clientLoginUrl = new URL("https://my.server.com:8443/accounts/ClientLogin"); 
    HttpURLConnection clientLoginSecureConnection = 
     (HttpURLConnection)clientLoginUrl.openConnection(proxy); 
    clientLoginSecureConnection.setDoInput(true); 
    clientLoginSecureConnection.setDoOutput(true); 
    clientLoginSecureConnection.setUseCaches(false); 
    clientLoginSecureConnection.setRequestProperty("Content-Type",   
     "application/x-www-form-urlencoded"); 
    StringBuilder content = new StringBuilder(); 
    content.append("Email=").append(
    URLEncoder.encode(Constants.GSA_AUTH_USER, "UTF-8")); 
    content.append("&Passwd=").append(
    URLEncoder.encode(Constants.GSA_AUTH_PASSWORD, "UTF-8")); 
    OutputStream outputStream = clientLoginSecureConnection.getOutputStream(); 
    outputStream.write(content.toString().getBytes("UTF-8")); 
    outputStream.close(); 
    // Retrieve the output 
    int responseCode = clientLoginSecureConnection.getResponseCode(); 
    System.out.println("Response code: " + responseCode); 
    InputStream inputStream; 
    if (responseCode == HttpURLConnection.HTTP_OK) { 
     inputStream = clientLoginSecureConnection.getInputStream(); 
    } else { 
     inputStream = clientLoginSecureConnection.getErrorStream(); 
    } 
    String postOutput = toString(inputStream); 
    StringTokenizer tokenizer = new StringTokenizer(postOutput, "=\n "); 
    String key = null; 
    while (tokenizer.hasMoreElements()) { 
     if (tokenizer.nextToken().equalsIgnoreCase("Auth")) { 
      if (tokenizer.hasMoreElements()) { 
       key = tokenizer.nextToken(); 
      } 
      break; 
     } 
    } 
    if (key == null) { 
    System.out.println("Error response from server:\n" + postOutput); 
    } else { 
     System.out.println("Key found: " + key); 
} 

:

javax.net.ssl.SSLHandshakeException을 :

내 코드 원격 호스트가 핸드 셰이크 중에 연결 폐쇄 at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord (SSLSocketImpl.java:808) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake (SSLSocketI mpl.java:1120) 에서 com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake (SSLSocketImpl.java:1147에서 ) com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake ( sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect에서 sun.net.www.protocol.https.HttpsClient.afterConnect (HttpsClient.java:434) (AbstractDelegateHttpsURLConnection.java에서 SSLSocketImpl.java:1131) : 166) sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream에서 sun.net.www.protocol.http.HttpURLConnection.getOutputStream (HttpURLConnection.java:904)에서 (HttpsURLConnectionImpl.java:230),536 sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39)에서 sun.reflect.NativeMethodAccessorImpl.invoke0 (기본 방법) 에서 com.mycompany.gslisting.GetKeysTestCase.testGetAccessControlListKeys (GetKeysTestCase.java:90) 에서에서 sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke (Method.java:597) at junit.framework.TestCase.runTest (TestCase.java:168) at 에서 junit.framework.TestResult의 $의 1.protect에서 junit.framework.TestCase.runBare (TestCase.java:134) junit.framework.TestResult.runProtected (TestResult.java:128)에서 (TestResult.java:110) jjunit.framework.TestCase.run (TestCase.java:124) at junit.framework.TestSuite.runTest (TestSuite.java:243) junit에서 unit.framework.TestResult.run (TestResult.java:113) org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run에서 framework.TestSuite.run org.junit.internal.runners.JUnit38ClassRunner.run (JUnit38ClassRunner.java:83)에서 (TestSuite.java:238) org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests에서 org.eclipse.jdt.internal.junit.runner.TestExecution.run (TestExecution.java:38)에서 (JUnit4TestReference.java:50) (RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit. runner.RemoteTestRunner.runTests (RemoteTestRunner.java:683) org.eclipse.jdt.internal.junit에서 org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run (RemoteTestRunner.java:390) 에서 . runner.RemoteTestRunner.main (RemoteTestRunner.java:197) 발생 원인 : java.io.EOFException : SSL 피어가 올바르게 종료되지 않음 com.sun.net.ssl.internal.ssl.InputRecord.read (InputRecord.java:333)) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord (SSLSocketImpl.java : 789) ... 27 더

아이디어가 있으십니까?

답변

0

발견!

방금 ​​this site의 지침을 따랐습니다. 브라우저 (Chrome)를 사용하여 사이트 인증서 (.cer)를 다운로드하고 다음을 실행하여 기본 키 저장소로 가져 오려고했습니다 :

#keytool -import -alias GSAAPI -file ./GSA.cer 
관련 문제