Rally Software

 View Only
  • 1.  peer not authenticated - Rally javatoolkit error

    Posted Apr 24, 2017 11:17 AM

    I have been using the rally javatoolkit for a while to add testcases, test results etc without any error. But all of a sudden it started throwing error as " javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated" . I have referred the pages "rally rest api java toolkit sslpeerunverifiedexception : peer not authenticated" , rally rest api java toolkit sslpeerunverifiedexception : peer not authenticated but they didn't help me. Can someone help me with what I am doing wrong. Also If i need to download a certificate please help me for windows system. Thanks in advance. my code is as below:

    import com.rallydev.rest.RallyRestApi; import com.rallydev.rest.client.HttpClient; import com.rallydev.rest.request.GetRequest; import com.rallydev.rest.response.GetResponse; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.security.cert.CertificateException; import java.security.cert.X509Certificate;  import org.apache.http.conn.ssl.SSLSocketFactory; import org.apache.http.conn.ssl.TrustStrategy; import org.apache.http.conn.scheme.Scheme;   public class ConnnectionTestWithHTTPClient {      public static void main(String[] args) throws URISyntaxException, IOException {           String host = "https://rally1.rallydev.com";         String apiKey = "_abc123";         String applicationName = "Connnection Test With HTTPClient";         RallyRestApi restApi = new RallyRestApi(new URI(host),apiKey);         restApi.setApplicationName(applicationName);          //restApi.setProxy(new URI("http://myproxy.mycompany.com"), "MyProxyUsername", "MyProxyPassword");  //SET PROXY SETTINS HERE         HttpClient client = restApi.getClient();         try {             SSLSocketFactory sf = new SSLSocketFactory(new TrustStrategy() {                 public boolean isTrusted(X509Certificate[] certificate, String authType)                     throws CertificateException {                     //trust all certs                     return true;                 }             }, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);             client.getConnectionManager().getSchemeRegistry().register(new Scheme("https", 443, sf));              String workspaceRef = "/workspace/12345"; //USE VALID WORKSPACE OID              GetRequest getRequest = new GetRequest(workspaceRef);             GetResponse getResponse = restApi.get(getRequest);             System.out.println(getResponse.getObject());         } catch (Exception e) {             System.out.println(e);         } finally {             restApi.close();         }        }  }

    Also adding to the issue, i found a different error when I changed the port from 443 to 8443. i get "java.io.IOException: HTTP/1.1 522 Origin Connection Time-out" when i use 8443.



  • 2.  Re: peer not authenticated - Rally javatoolkit error

    Posted Apr 24, 2017 12:10 PM

    For some reason when I uncomment the line //restApi.setProxy(new URI("http://myproxy.mycompany.com"), "MyProxyUsername", "MyProxyPassword"); with correct inputs, the error goes off. For all those who need the inputs, please put in the following:

    restApi.setProxy(new URI("http://rally1.rallydev.com"), "xyz@abc.com", "rallypassword");

    so the working code is as below:

    import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.security.cert.CertificateException; import java.security.cert.X509Certificate;  import org.apache.http.conn.scheme.Scheme; import org.apache.http.conn.ssl.SSLSocketFactory; import org.apache.http.conn.ssl.TrustStrategy; import com.rallydev.rest.RallyRestApi; import com.rallydev.rest.client.HttpClient; import com.rallydev.rest.request.GetRequest; import com.rallydev.rest.response.GetResponse;  public class ConnnectionTestWithHTTPClient {      public static void main(String[] args) throws URISyntaxException, IOException {           String host = "https://rally1.rallydev.com";         String apiKey = "_apikey";          String applicationName = "Connnection Test With HTTPClient";         RallyRestApi restApi = new RallyRestApi(new URI(host),apiKey);         restApi.setApplicationName(applicationName);          restApi.setProxy(new URI("http://rally1.rallydev.com"), "abc@abc.com", "rallypassword");  //YOUR PROXY SETTINGS HERE         HttpClient client = restApi.getClient();         try {             SSLSocketFactory sf = new SSLSocketFactory(new TrustStrategy() {                 public boolean isTrusted(X509Certificate[] certificate, String authType)                     throws CertificateException {                     //trust all certs                     return true;                 }             }, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);             client.getConnectionManager().getSchemeRegistry().register(new Scheme("https", 443, sf));              String workspaceRef = "/workspace/1234";              GetRequest getRequest = new GetRequest(workspaceRef);             GetResponse getResponse = restApi.get(getRequest);             System.out.println(getResponse.getObject());         } catch (Exception e) {             System.out.println(e);         } finally {             restApi.close();         }        }  }


  • 3.  RE: Re: peer not authenticated - Rally javatoolkit error

    Posted Jul 21, 2020 10:58 AM
    Hi,

    i am also using the same code but the issue was not resolved. Could you please assist me to proceed further..

    Error:Exception in thread "main" javax.net.ssl.SSLPeerUnverifiedException: peer not authenticatedException in thread "main" javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated at sun.security.ssl.SSLSessionImpl.getPeerCertificates(SSLSessionImpl.java:431) at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:126) at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:437) at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:180) at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:294) at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:643) at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:479) at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906) at org.apache.http.impl.client.DecompressingHttpClient.execute(DecompressingHttpClient.java:137) at org.apache.http.impl.client.DecompressingHttpClient.execute(DecompressingHttpClient.java:108) at com.rallydev.rest.client.HttpClient.executeRequest(HttpClient.java:157) at com.rallydev.rest.client.HttpClient.doRequest(HttpClient.java:145) at com.rallydev.rest.client.ApiKeyClient.doRequest(ApiKeyClient.java:37) at com.rallydev.rest.client.HttpClient.doGet(HttpClient.java:221) at com.rallydev.rest.RallyRestApi.query(RallyRestApi.java:168) at com.java.Testingurl.main(Testingurl.java:54)

    Code : same code which u mention in the above.