{"id":5423,"date":"2016-02-23T14:39:07","date_gmt":"2016-02-23T19:39:07","guid":{"rendered":"http:\/\/appcrawler.com\/wordpress\/?p=5423"},"modified":"2016-02-23T14:40:34","modified_gmt":"2016-02-23T19:40:34","slug":"unable-to-find-valid-certification-path-to-requested-target-exception","status":"publish","type":"post","link":"http:\/\/appcrawler.com\/wordpress\/2016\/02\/23\/unable-to-find-valid-certification-path-to-requested-target-exception\/","title":{"rendered":"&#8220;Unable to find valid certification path to requested target&#8221; exception"},"content":{"rendered":"<p>In a JBOSS environment, the issue was the connector in the server.xml file is only used for *inbound* connections, not ones out from JBOSS to another SSL enabled service.  If you compile and run the following test class below\u2026<\/p>\n<pre>\r\n[sa-jboss@cmhldecomecm01 ~]$ cat checkSSL.java\r\nimport java.io.*;\r\nimport javax.net.ssl.*;\r\n\r\npublic class checkSSL {\r\n  public static void main(String[] args) throws Exception {\r\n    SSLSocketFactory sslFactory = (SSLSocketFactory)SSLSocketFactory.getDefault();\r\n    SSLSocket sslSocket = (SSLSocket)sslFactory.createSocket(args[0], Integer.parseInt(args[1]));\r\n\r\n    InputStream is = sslSocket.getInputStream();\r\n    OutputStream os = sslSocket.getOutputStream();\r\n\r\n    os.write(1);\r\n    while (is.available() > 0) {\r\n      System.out.print(is.read());\r\n    }\r\n    System.out.println(\"Successfully connected\");\r\n  }\r\n}\r\n<\/pre>\n<p>\u2026you will see it doesn\u2019t work when the default cacerts file is used\u2026<\/p>\n<pre>\r\n[sa-jboss@cmhldecomecm01 ~]$ \/usr\/lib\/jvm\/java-1.7.0\/jre\/bin\/java -Djavax.net.ssl.trustStore=\/usr\/lib\/jvm\/java-1.7.0\/jre\/lib\/security\/cacerts checkSSL cmhldmomsesb01 61617\r\nException in thread \"main\" javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target\r\n<\/pre>\n<p>\u2026but works when pointed to either a custom keystore\u2026<\/p>\n<pre>\r\n[sa-jboss@cmhldecomecm01 ~]$ \/usr\/lib\/jvm\/java-1.7.0\/jre\/bin\/java -Djavax.net.ssl.trustStore=\/opt\/jboss\/security\/domain.com.keystore checkSSL cmhldmomsesb01 61617\r\nSuccessfully connected\r\n[sa-jboss@cmhldecomecm01 ~]$\r\n<\/pre>\n<p>\u2026or to a cacerts into which the custom certificate has been imported\u2026<\/p>\n<pre>\r\n[sa-jboss@cmhldecomecm01 ~]$ \/usr\/lib\/jvm\/java-1.7.0\/jre\/bin\/java -Djavax.net.ssl.trustStore=\/tmp\/cacerts checkSSL cmhldmomsesb01 61617\r\nSuccessfully connected\r\n[sa-jboss@cmhldecomecm01 ~]$\r\n<\/pre>\n<p>Two possible solutions exist:<\/p>\n<p>1.       Change the JBOSS arguments file (\/opt\/jboss\/run\/ecm_02.conf) to add the \u201c-Djavax.net.ssl.trustStore=\/opt\/jboss\/security\/domain.com.keystore\u201d argument<br \/>\n2.       Import the custom key into the cacerts file in the default JRE location (\/usr\/lib\/jvm\/java-1.7.0\/jre\/lib\/security\/cacerts)<\/p>\n<p>Either one would do it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In a JBOSS environment, the issue was the connector in the server.xml file is only used for *inbound* connections, not ones out from JBOSS to another SSL enabled service. If you compile and run the following test class below\u2026 [sa-jboss@cmhldecomecm01&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"http:\/\/appcrawler.com\/wordpress\/2016\/02\/23\/unable-to-find-valid-certification-path-to-requested-target-exception\/\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"footnotes":""},"categories":[25,49],"tags":[],"_links":{"self":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/5423"}],"collection":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/comments?post=5423"}],"version-history":[{"count":7,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/5423\/revisions"}],"predecessor-version":[{"id":5431,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/5423\/revisions\/5431"}],"wp:attachment":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/media?parent=5423"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/categories?post=5423"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/tags?post=5423"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}