{"id":576,"date":"2014-03-01T15:42:36","date_gmt":"2014-03-01T15:42:36","guid":{"rendered":"http:\/\/www.theSQLReport.com\/?p=576"},"modified":"2014-11-19T11:59:38","modified_gmt":"2014-11-19T11:59:38","slug":"moving-a-certificate-from-windows-to-the-java-cacerts-file","status":"publish","type":"post","link":"http:\/\/www.theSQLReport.com\/?p=576","title":{"rendered":"Moving a Certificate from Windows to the Java Cacerts File"},"content":{"rendered":"<p>Recently I had a server with a java application that one day stopped authenticating users.\u00a0 I was able to trace it back to the JDK\u00a0 (java developer kit) that the java application software was using.\u00a0 In the JDK&#8217;s keystore file (cacerts), the certificate used in its authentication was expired.\u00a0 Below is the steps I took to move an updated certificate from Windows to the JDK cacerts keystore file.\u00a0\u00a0 Also this will work for updating the JRE&#8217;s (java runtime environment) keystore file (cacerts).<\/p>\n<p>Note:\u00a0 In my example I am going to use the Go Daddy certificate.\u00a0 This certificate is probably similar to any certificate that would be used in your environment for authentication.\u00a0 New version of the JDK already have the GoDaddy certificate in its keystore.<\/p>\n<p>1. Open the Windows Certificate Manager by clicking the Start button, then typing <strong>certmgr.msc<\/strong> in the search text box and clicking the enter button.<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/certmgr.msc_.jpg\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-584\" src=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/certmgr.msc_.jpg\" alt=\"certmgr.msc\" width=\"406\" height=\"504\" srcset=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/certmgr.msc_.jpg 406w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/certmgr.msc_-241x300.jpg 241w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/certmgr.msc_-169x210.jpg 169w\" sizes=\"(max-width: 406px) 100vw, 406px\" \/><\/a><\/p>\n<p>2. Once the Windows Certificate Manager opens, in the left panel click on the &#8220;<strong>Trusted Root Certificate Authorities<\/strong>&#8221; folder, then click on the <strong>Certificates<\/strong> folder.\u00a0 Then in the right panel, select the certificate that you going to copy.\u00a0 In my example, I am choosing the Go Daddy certificate.<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/WindowsCertificateManager.jpg\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-594\" src=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/WindowsCertificateManager.jpg\" alt=\"WindowsCertificateManager\" width=\"1168\" height=\"444\" srcset=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/WindowsCertificateManager.jpg 1168w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/WindowsCertificateManager-300x114.jpg 300w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/WindowsCertificateManager-1024x389.jpg 1024w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/WindowsCertificateManager-210x79.jpg 210w\" sizes=\"(max-width: 1168px) 100vw, 1168px\" \/><\/a><\/p>\n<p>3.\u00a0 Right click on the certificate highlighted, and scroll down to <strong>All Tasks<\/strong>, then click on <strong>Export<\/strong>.<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/ExportCertificateFromWindows.jpg\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-586\" src=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/ExportCertificateFromWindows.jpg\" alt=\"ExportCertificateFromWindows\" width=\"1164\" height=\"461\" srcset=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/ExportCertificateFromWindows.jpg 1164w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/ExportCertificateFromWindows-300x118.jpg 300w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/ExportCertificateFromWindows-1024x405.jpg 1024w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/ExportCertificateFromWindows-210x83.jpg 210w\" sizes=\"(max-width: 1164px) 100vw, 1164px\" \/><\/a><\/p>\n<p>4.\u00a0 The Certificate Export Wizard will appear, click on the <strong>Next<\/strong> button.<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/CertificateExportWizard.jpg\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-583\" src=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/CertificateExportWizard.jpg\" alt=\"CertificateExportWizard\" width=\"502\" height=\"452\" srcset=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/CertificateExportWizard.jpg 502w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/CertificateExportWizard-300x270.jpg 300w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/CertificateExportWizard-210x189.jpg 210w\" sizes=\"(max-width: 502px) 100vw, 502px\" \/><\/a><\/p>\n<p>5. The Export File Format screen will appear.\u00a0 Leave it at the default &#8220;DER encoded binary X.509 (.CER)&#8221;.\u00a0 Click the <strong>Next<\/strong> button.<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/ExportFileFormat.X.509.jpg\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-587\" src=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/ExportFileFormat.X.509.jpg\" alt=\"ExportFileFormat.X.509\" width=\"500\" height=\"453\" srcset=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/ExportFileFormat.X.509.jpg 500w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/ExportFileFormat.X.509-300x271.jpg 300w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/ExportFileFormat.X.509-210x190.jpg 210w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><\/p>\n<p>6. In the File to Export screen, click the <strong>Browse<\/strong> button to name &amp; save the certificate in the chosen location.<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/FileToExport.jpg\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter  wp-image-588\" src=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/FileToExport.jpg\" alt=\"FileToExport\" width=\"501\" height=\"453\" srcset=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/FileToExport.jpg 501w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/FileToExport-300x271.jpg 300w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/FileToExport-210x189.jpg 210w\" sizes=\"(max-width: 501px) 100vw, 501px\" \/><\/a><\/p>\n<p>7.\u00a0 I like to save the certificate in the same directory as the JDK&#8217;s keystore file (cacerts).\u00a0 Name the certificate, and click the <strong>Save<\/strong> button.<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/SavingTheCertificate.jpg\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-597\" src=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/SavingTheCertificate.jpg\" alt=\"SavingTheCertificate\" width=\"633\" height=\"567\" srcset=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/SavingTheCertificate.jpg 633w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/SavingTheCertificate-300x268.jpg 300w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/SavingTheCertificate-210x188.jpg 210w\" sizes=\"(max-width: 633px) 100vw, 633px\" \/><\/a><\/p>\n<p>8. This returns to the File to Export screen, click the <strong>Next<\/strong> button.<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/FileToExportNext.jpg\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-589\" src=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/FileToExportNext.jpg\" alt=\"FileToExportNext\" width=\"500\" height=\"451\" srcset=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/FileToExportNext.jpg 500w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/FileToExportNext-300x270.jpg 300w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/FileToExportNext-210x189.jpg 210w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><\/p>\n<p>9.\u00a0 The Completing the Certificate Export Wizard screen appears, click on the <strong>Finish<\/strong> button.<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/CertificateExportWizard.jpg\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-583\" src=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/CertificateExportWizard.jpg\" alt=\"CertificateExportWizard\" width=\"502\" height=\"452\" srcset=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/CertificateExportWizard.jpg 502w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/CertificateExportWizard-300x270.jpg 300w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/CertificateExportWizard-210x189.jpg 210w\" sizes=\"(max-width: 502px) 100vw, 502px\" \/><\/a><\/p>\n<p>10.\u00a0 A pop box may appear notifying that the export was successful.\u00a0 Click the <strong>OK<\/strong> button, and the wizard closes.\u00a0 It is now OK to close the\u00a0Windows Certificate Manager.<\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/PopUp.jpg\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-592\" src=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/PopUp.jpg\" alt=\"PopUp\" width=\"184\" height=\"124\" srcset=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/PopUp.jpg 184w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/PopUp-300x203-1393688846.jpg 300w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/PopUp-1024x694-1393688846.jpg 1024w\" sizes=\"(max-width: 184px) 100vw, 184px\" \/><\/a><\/p>\n<p>11.\u00a0 Next find the location of the keytool file, and the cacerts file in your JDK location. They will be needed for the importing of the certificate.<\/p>\n<ul>\n<li>In my example, the keytool executable file was stored in the default location for the JDK: C:\\Program Files\\Java\\jdk1.7.0_51\\bin<\/li>\n<\/ul>\n<ul>\n<li>In my example, the JDK keystore &#8211; cacerts file was stored in the default location for the JDK: C:\\Program Files\\Java\\jdk1.7.0_51\\jre\\lib\\security<\/li>\n<\/ul>\n<p>12. Open a command prompt window to the directory that the keytool executable file is in, and test it by running the command: <strong>keytool -help<\/strong><\/p>\n<p style=\"text-align: center;\"><a href=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/KeytoolHelp.jpg\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter  wp-image-590\" src=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/KeytoolHelp.jpg\" alt=\"KeytoolHelp\" width=\"666\" height=\"331\" srcset=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/KeytoolHelp.jpg 666w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/KeytoolHelp-300x149.jpg 300w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/KeytoolHelp-210x104.jpg 210w\" sizes=\"(max-width: 666px) 100vw, 666px\" \/><\/a><\/p>\n<p>13. Enter the keytool command to import the certificate.\u00a0 Please note that the alias is the name you want for the certificate, which in my example is: &#8220;GoDaddy&#8221;.\u00a0 The double quotes are needed to if the name contains spaces.\u00a0 In my example I used the full name with location for the cacerts file and the certificate that I am importing.<\/p>\n<p>Note:\u00a0 This certificate already exist in the keystore file by default, however I am still using it for this example.<\/p>\n<pre><strong>keytool -import -alias &lt;your alias name&gt; -keystore &lt;cacerts location&gt; -trustcacerts -file &lt;certificate location&gt;<\/strong><\/pre>\n<p style=\"text-align: left;\"><a href=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/KeytoolImportPromptPassword.jpg\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter  wp-image-591\" src=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/KeytoolImportPromptPassword.jpg\" alt=\"KeytoolImportPromptPassword\" width=\"907\" height=\"162\" srcset=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/KeytoolImportPromptPassword.jpg 907w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/KeytoolImportPromptPassword-300x53.jpg 300w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/KeytoolImportPromptPassword-210x37.jpg 210w\" sizes=\"(max-width: 907px) 100vw, 907px\" \/><\/a><\/p>\n<p style=\"text-align: left;\">If prompted for a password, enter the one for your java keystore.\u00a0 If a password was not set for this keystore, the default is: <strong>changeit<\/strong><\/p>\n<p>14.\u00a0\u00a0 Many line will scroll with security information regarding the certificate.\u00a0 You will be prompted if you would like to trust this certificate.\u00a0 Type <strong>yes<\/strong>, then click enter button.\u00a0 Then the line returned will let you know if the certificate was added successfully.<\/p>\n<p style=\"text-align: left;\"><a href=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/CertificateAdded.jpg\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-582\" src=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/CertificateAdded.jpg\" alt=\"CertificateAdded\" width=\"906\" height=\"111\" srcset=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/CertificateAdded.jpg 906w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/CertificateAdded-300x36.jpg 300w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/CertificateAdded-210x25.jpg 210w\" sizes=\"(max-width: 906px) 100vw, 906px\" \/><\/a><\/p>\n<p style=\"text-align: left;\">Note: If you should get a java.io error about writing the certificate, temporarily change the write permissions for the security folder where the cacerts file exists.<\/p>\n<p>15.\u00a0 Verify that the certificate was added by using the keytool command with the list option.\u00a0 Enter the password again if prompted.<\/p>\n<pre><strong>keytool -list -keystore &lt;cacerts location&gt;<\/strong><\/pre>\n<p style=\"text-align: center;\"><a href=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/VerifyCertificate.jpg\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter  wp-image-598\" src=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/VerifyCertificate.jpg\" alt=\"VerifyCertificate\" width=\"908\" height=\"235\" srcset=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/VerifyCertificate.jpg 908w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/VerifyCertificate-300x77.jpg 300w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/VerifyCertificate-210x54.jpg 210w\" sizes=\"(max-width: 908px) 100vw, 908px\" \/><\/a><\/p>\n<p>16.\u00a0 A long list will appear, and you will have search for your certificate to verify.<\/p>\n<p style=\"text-align: left;\"><a href=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/VerifyTrustCertificateList.jpg\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-599\" src=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/VerifyTrustCertificateList.jpg\" alt=\"VerifyTrustCertificateList\" width=\"906\" height=\"306\" srcset=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/VerifyTrustCertificateList.jpg 906w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/VerifyTrustCertificateList-300x101.jpg 300w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2014\/02\/VerifyTrustCertificateList-210x70.jpg 210w\" sizes=\"(max-width: 906px) 100vw, 906px\" \/><\/a><\/p>\n<p style=\"text-align: left;\">Note: In running the keytool list, piping the results to the find command will bring back the name &amp; expiration date.\u00a0 Again a password prompt may appear.<\/p>\n<pre><strong>keytool -list -keystore &lt;cacerts location&gt; | find \" &lt;alias name&gt; \"<\/strong><\/pre>\n<p>Final Note: After installing the certificate, may need to restart your java application for it to start using the new certificate.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently I had a server with a java application that one day stopped authenticating users.\u00a0 I was able to trace it back to the JDK\u00a0 (java developer kit) that the &hellip; <a class=\"readmore\" href=\"http:\/\/www.theSQLReport.com\/?p=576\">Continue Reading &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":592,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[39,40,37,38],"class_list":["post-576","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-windows","tag-cacerts","tag-certmgr-msc","tag-jdk","tag-keystore"],"_links":{"self":[{"href":"http:\/\/www.theSQLReport.com\/index.php?rest_route=\/wp\/v2\/posts\/576"}],"collection":[{"href":"http:\/\/www.theSQLReport.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.theSQLReport.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.theSQLReport.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.theSQLReport.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=576"}],"version-history":[{"count":20,"href":"http:\/\/www.theSQLReport.com\/index.php?rest_route=\/wp\/v2\/posts\/576\/revisions"}],"predecessor-version":[{"id":782,"href":"http:\/\/www.theSQLReport.com\/index.php?rest_route=\/wp\/v2\/posts\/576\/revisions\/782"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.theSQLReport.com\/index.php?rest_route=\/wp\/v2\/media\/592"}],"wp:attachment":[{"href":"http:\/\/www.theSQLReport.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=576"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.theSQLReport.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=576"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.theSQLReport.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=576"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}