{"id":1746,"date":"2014-03-03T17:38:17","date_gmt":"2014-03-03T15:38:17","guid":{"rendered":"http:\/\/raftaman.net\/?p=1746"},"modified":"2021-05-15T11:46:37","modified_gmt":"2021-05-15T09:46:37","slug":"revoking-an-openvpn-certificate","status":"publish","type":"post","link":"https:\/\/possiblelossofprecision.net\/?p=1746","title":{"rendered":"Revoking an OpenVPN certificate"},"content":{"rendered":"<p>One of the great advantages of using OpenVPN with <a href=\"http:\/\/openvpn.net\/index.php\/open-source\/documentation\/miscellaneous\/rsa-key-management.html\">RSA keys<\/a> instaed of <a href=\"http:\/\/openvpn.net\/index.php\/open-source\/documentation\/miscellaneous\/78-static-key-mini-howto.html\">static keys<\/a> is the fact that you can easily disable access to the server for a specific client without the need to re-create keys for any other client. This is called revoking of client certificates.<\/p>\n<p>Since every single client&#8217;s certificate is verified against a <em>Certificate Revoking List<\/em> (CRL), disabling a certificate is rather easy. We simply have to create a <em>CRL<\/em> file and tell OpenVPN to use it. Any match against the <em>CRL<\/em> will then result in the connection being dropped.<\/p>\n<h2>Create a CRL file<\/h2>\n<p>The simplest way of dealing with RSA key management in general is probably <code>easy-rsa<\/code>. You probably set up your OpenVPN server with the help of easy-rsa in the first place, so creating the CRL file is as simple as<\/p>\n<pre class=\"brush: bash; highlight: [10]; title: ; notranslate\" title=\"\">\r\n# cd \/usr\/share\/easy-rsa\/2.0\/\r\n# source .\/vars \r\nNOTE: If you run .\/clean-all, I will be doing a rm -rf on \/usr\/share\/easy-rsa\/2.0\/keys\r\n# .\/revoke-full client\r\nUsing configuration from \/usr\/share\/easy-rsa\/2.0\/openssl-1.0.0.cnf\r\nRevoking Certificate 04.\r\nData Base Updated\r\nUsing configuration from \/usr\/share\/easy-rsa\/2.0\/openssl-1.0.0.cnf\r\nclient.crt: C = US, ST = CA, L = City, O = name, OU = name.example.org, CN = client, name = client, emailAddress = openvpn@example.org\r\nerror 23 at 0 depth lookup:certificate revoked\r\n<\/pre>\n<p>As you can see in the last line, the certificate was successfully revoke (hence the verification <strong>error 23<\/strong>).<\/p>\n<p>You can also see the revoked status of the client&#8217;s certificate in the <code>keys\/index.txt<\/code> file. An <strong>&#8220;R&#8221;<\/strong> in the first column indicates, that the certificate was revoked.<\/p>\n<pre class=\"brush: plain; title: keys\/index.txt; notranslate\" title=\"keys\/index.txt\">\r\n&#x5B;...]\r\nR       240209140518Z   140211140526Z   04      unknown \/C=US\/ST=CA\/L=City\/O=name\/OU=name.example.org\/CN=client\/name=client\/emailAddress=openvpn@example.org\r\n<\/pre>\n<p>To examine the newly created CRL file, use<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n# openssl crl -in keys\/crl.pem -text\r\n<\/pre>\n<h2>Configure OpenVPN to use a CRL<\/h2>\n<p>Next, we need to tell OpenVPN to verify incoming connections against against our CRL. Copy the <code>crl.pem<\/code> file to the OpenVPN config directory and assure, that&#8217;s it&#8217;s readable to the user running the OpenVPN service (usually openvpn:openvpn).<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n# cp -a keys\/crl.pem \/etc\/openvpn\/keys\/\r\n# chmod 755 \/etc\/openvpn\/keys\/\r\n<\/pre>\n<p>To tell the OpenVPN server to use a CRL, add the following line to your server&#8217;s config file:<\/p>\n<pre class=\"brush: plain; title: \/etc\/openvpn\/server.conf; notranslate\" title=\"\/etc\/openvpn\/server.conf\">\r\n&#x5B;...]\r\ncrl-verify keys\/crl.pem\r\n<\/pre>\n<p>After <strong>restarting the OpenVPN server<\/strong>, every connection from a client with a revoked certificate should be denied<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n# journalctl -f\r\n&#x5B;...]\r\nFeb 11 15:27:05 OpenVPN openvpn&#x5B;493]: 192.168.8.35:51960 CRL CHECK FAILED: C=US, ST=CA, L=City, O=name, OU=name.example.org, CN=client, name=client, emailAddress=openvpn@example.org is REVOKED\r\n&#x5B;...]\r\n<\/pre>\n<p>Resources:<br \/>\n<a href=\"http:\/\/blog.remibergsma.com\/2013\/02\/27\/improving-openvpn-security-by-revoking-unneeded-certificates\/\">http:\/\/blog.remibergsma.com\/2013\/02\/27\/improving-openvpn-security-by-revoking-unneeded-certificates\/<\/a><br \/>\nSee also <a href=\"https:\/\/community.openvpn.net\/openvpn\/wiki\/Openvpn23ManPage\">OpenVPN 2.3 manpage<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the great advantages of using OpenVPN with RSA keys instaed of static keys is the fact that you can easily disable access to the server for a specific client without the need to re-create keys for any other client. This is called revoking of client certificates. Since every single client&#8217;s certificate is verified against a Certificate Revoking List&#8230; <a href=\"https:\/\/possiblelossofprecision.net\/?p=1746\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[7,66],"class_list":["post-1746","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-fedora","tag-openvpn"],"_links":{"self":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts\/1746","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1746"}],"version-history":[{"count":12,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts\/1746\/revisions"}],"predecessor-version":[{"id":2190,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts\/1746\/revisions\/2190"}],"wp:attachment":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1746"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1746"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1746"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}