{"id":8852,"date":"2021-09-04T21:19:00","date_gmt":"2021-09-04T21:19:00","guid":{"rendered":"https:\/\/putridparrot.com\/blog\/?p=8852"},"modified":"2021-09-04T21:19:00","modified_gmt":"2021-09-04T21:19:00","slug":"adding-certificates-to-the-java-cacerts-or-fixing-pkix-path-issue","status":"publish","type":"post","link":"https:\/\/putridparrot.com\/blog\/adding-certificates-to-the-java-cacerts-or-fixing-pkix-path-issue\/","title":{"rendered":"Adding certificates to the Java cacerts (or fixing PKIX path issue)"},"content":{"rendered":"<p>I&#8217;m back on some Java coding after a fair time away and was getting the old <em>PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException<\/em> error.<\/p>\n<p>Basically Java is complaining that it didn&#8217;t recognise the HTTPS SSL certificate of the maven repository (in this case one hosted in Artifactory). Here&#8217;s the steps to resolve this&#8230;.<\/p>\n<p><em>Note: Instructions are on Windows using Chrome, but should be similar in different browsers.<\/em><\/p>\n<ul>\n<li>Open the HTTPS repository in Chrome (or preferred web browser)<\/li>\n<li>Use the dev tools (ctrl+shift+i) and select the Security tab<\/li>\n<li>Click on the <em>View certificate<\/em> button<\/li>\n<li>Select the Details tab<\/li>\n<li>Click the <em>Copy to file&#8230;<\/em> button<\/li>\n<li>Click <em>Next<\/em> until you see the format selector, I used DER format<\/li>\n<li>Click <em>Next<\/em> etc. and save the exported cert to your hard drive<\/li>\n<\/ul>\n<p>Let&#8217;s assume we saved the file as mycert.cer, now we need to import this into the cacert using the keytool&#8230; <\/p>\n<ul>\n<li>Go to the location of the JDK\/JRE you&#8217;re using, for example C:\\Program Files\\Java\\jdk1.8.0_101\\jre\\lib\\security<\/li>\n<li>Open a command prompt and type\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nkeytool -import -alias mycert -keystore &quot;C:\\Program Files\\Java\\jdk1.8.0_101\\jre\\lib\\security\\cacerts&quot; -file mycert.cer\r\n<\/pre>\n<p>Replace the first occurence of mycert with a unique name (key) for your certificate and then obviously the mycert.cer is replaced with the name of the certificate file you saved.\n<\/li>\n<li>You&#8217;ll be asked for a password, the default is <strong>changeit<\/strong> obviously if this has been changed then use that<\/li>\n<li>Type <em>yes<\/em> when prompted if you want to proceed<\/li>\n<\/ul>\n<p>That&#8217;s it &#8211; the certificate should now be available to Java.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m back on some Java coding after a fair time away and was getting the old PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException error. Basically Java is complaining that it didn&#8217;t recognise the HTTPS SSL certificate of the maven repository (in this case one hosted in Artifactory). Here&#8217;s the steps to resolve this&#8230;. Note: Instructions are on [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[161],"tags":[],"class_list":["post-8852","post","type-post","status-publish","format-standard","hentry","category-java"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/8852","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/comments?post=8852"}],"version-history":[{"count":2,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/8852\/revisions"}],"predecessor-version":[{"id":8912,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/8852\/revisions\/8912"}],"wp:attachment":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/media?parent=8852"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/categories?post=8852"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/tags?post=8852"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}