{"id":2925,"date":"2018-11-13T11:32:07","date_gmt":"2018-11-13T11:32:07","guid":{"rendered":"http:\/\/blog.designed79.co.uk\/?p=2925"},"modified":"2019-01-21T10:37:10","modified_gmt":"2019-01-21T10:37:10","slug":"renew-root-ca-cert-made-with-certificate-assistant-on-macos","status":"publish","type":"post","link":"https:\/\/blog.designed79.co.uk\/?p=2925","title":{"rendered":"Renew Root CA Cert made with Certificate Assistant on macOS"},"content":{"rendered":"<p><strong>NOTE : a good open source cross platform CA is xca,\u00a0https:\/\/github.com\/chris2511\/xca<\/strong><\/p>\n<p>Basically, you can create a new CA using the same private key and subject from the old CA. You replace the old CA certificate with the new one in Keychain Access. Finally, you continue creating or signing certificates in the normal way using Certificate Assistant.<\/p>\n<p>Please try these steps using a test CA first. Make sure they work as expected with the test CA. That way if anything goes wrong, you won&#8217;t have affected your actual CA. Make a backup copy of your old CA before making any changes to it. Let me know if you have any questions.<\/p>\n<p>Note: These instructions assume you need to renew a root CA and not an intermediate CA.<\/p>\n<p>Procedure:<\/p>\n<p>1. In Keychain Access, export your CA&#8217;s certificate as &#8220;old.cer&#8221;.<\/p>\n<p>2. Convert the old CA certificate to a new PEM format file &#8220;old.crt&#8221;:<\/p>\n<p>openssl x509 -inform der -in old.cer -out old.crt<\/p>\n<p>3. In Keychain Access, export your CA&#8217;s private key as &#8220;old.p12&#8221;.<br \/>\nThis will require you to set a passphrase to protect the exported file.<\/p>\n<p>4. Convert the old CA private key to a new PEM format file &#8220;old.key&#8221;:<\/p>\n<p>openssl pkcs12 -in old.p12 -out old.key<\/p>\n<p>5. Make a backup of your old CA, including the old.* files and all files here:<\/p>\n<p>~\/Library\/Application Support\/Certificate Authority\/Name of CA<\/p>\n<p>6. Create an openssl.cnf file with settings that match your old CA cert.<br \/>\nHere is a minimal example:<\/p>\n<p>[ req ]<br \/>\ndistinguished_name = req_distinguished_name<br \/>\n[ req_distinguished_name ]<br \/>\n[ v3_ca ]<br \/>\nbasicConstraints = critical, CA:TRUE<br \/>\nkeyUsage = critical, keyCertSign, keyEncipherment, digitalSignature<br \/>\nextendedKeyUsage = critical, serverAuth<\/p>\n<p>or<\/p>\n<p>[ req ]<br \/>\ndistinguished_name = req_distinguished_name<br \/>\n[ req_distinguished_name ]<br \/>\n[ v3_ca ]<br \/>\nbasicConstraints = critical, CA:TRUE<br \/>\nkeyUsage=critical, digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment, keyAgreement, keyCertSign, cRLSign<br \/>\nextendedKeyUsage=critical, emailProtection, clientAuth, serverAuth, codeSigning, 1.3.6.1.5.2.3.4, 1.3.6.1.5.2.3.5, 2.5.29.37.0<\/p>\n<p>You may need to change the keyUsage and extendedKeyUsage lines to match your old CA. See the x509v3_config(5) man page for more info.<\/p>\n<p>7. Get the subject string from the old CA cert with this command:<\/p>\n<p>openssl x509 -noout -subject -in old.crt<\/p>\n<p>It should be a single line this:<\/p>\n<p>CN=My Example CA, <a href=\"mailto:C=US\/emailAddress=user@example.com\">C<\/a>=US\/emailAddress=user@example.com<\/p>\n<p>You may have more fields in your subject for city, organization, etc. You&#8217;ll use this in the next step when creating a CSR for the new CA. \u00a0Ignore the <strong>subject=<\/strong> part<\/p>\n<p>8. Create a new signing request using the old CA&#8217;s key and the openssl.cnf<br \/>\nfile created in the last step:<\/p>\n<p>openssl req -config openssl.cnf -extensions v3_ca -new -key old.key -sha256 -out new.csr -subj &#8220;SUBJECT_STRING_FROM_PREVIOUS_STEP&#8221;<\/p>\n<p>9. Sign the new CA certificate using your old CA&#8217;s key:<\/p>\n<p>openssl x509 -req -extfile openssl.cnf -extensions v3_ca -days 365 -in new.csr -signkey old.key -sha256 -out new.crt<\/p>\n<p>Note that you can change the &#8220;-days&#8221; option if 365 days isn&#8217;t enough time before the CA cert expires. 7250 is about the max you can use<\/p>\n<p>Also note this will create a random serial number for the new cert which shouldn&#8217;t interfere with serial numbers used by any of your existing signed certs.<\/p>\n<p>10. Find an old certificate that you signed with your old CA. Verify the certificate using your old and new CA certs:<\/p>\n<p>openssl verify -CAfile old.crt -verbose some_old_cert.crt<br \/>\nopenssl verify -CAfile new.crt -verbose some_old_cert.crt<\/p>\n<p>Do not proceed unless both report &#8220;OK&#8221;. If the new one doesn&#8217;t say &#8220;OK&#8221;, something went wrong.<\/p>\n<p>11. Drag new.crt into Keychain Access. You will now have two identically named certificates which share the same private key. You will be able to tell which one is newer by the &#8220;Expires&#8221; column.<\/p>\n<p>12. Delete the old root CA cert in Keychain Access. DO NOT delete its private key, since it is now the private key for the new CA cert.<\/p>\n<p>13. Continue using the CA through Certificate Assistant as before. Test this by signing some new certificates.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>NOTE : a good open source cross platform CA is xca,\u00a0https:\/\/github.com\/chris2511\/xca Basically, you can create a new CA using the same private [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2925","post","type-post","status-publish","format-standard","hentry","category-info-on-tech"],"_links":{"self":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/2925","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2925"}],"version-history":[{"count":0,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/2925\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2925"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2925"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2925"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}