{"id":137,"date":"2023-01-29T20:44:25","date_gmt":"2023-01-29T20:44:25","guid":{"rendered":"https:\/\/www.titley.com\/?page_id=137"},"modified":"2023-01-29T21:49:38","modified_gmt":"2023-01-29T21:49:38","slug":"creating-self-signed-certificates-for-a-wpa-enterprise-wifi-using-freeradius","status":"publish","type":"page","link":"https:\/\/www.titley.com\/index.php\/about-us\/nigel\/creating-self-signed-certificates-for-a-wpa-enterprise-wifi-using-freeradius\/","title":{"rendered":"Creating self signed certificates for a WPA enterprise wifi, using FreeRadius"},"content":{"rendered":"\n<p>Using FreeRadius to authenticate your WPA enterprise mobile users is comparatively easy especially if you use daloRadius to manage your users however setting up the certificates that you need for it to work with more recent android phones is poorly documented and if you only have a hazy idea of how certificates work can be frustrating.<\/p>\n\n\n\n<p>In this short article I&#8217;ll try and explain how to set up FreeRadius with PEAP authentication including what to do to install the Certification Authority certificate on your android mobile.<\/p>\n\n\n\n<p>I&#8217;m not going to explain how to install FreeRadius or daloRadius. There are good tutorials out on the web and it is comparatively simple to set up your server. What is less obvious is setting up the certificates you need for your phone to accept that the radius server you are running is the one that it expects. Consider why this is important. In a corporate setting, or something like a university campus it is quite possible for a bad character to set up a wireless access point (WAP) that masquerades as the official network. If a user can be fooled into connecting to this bogus network then all his data is available for inspection: credit card numbers, passwords and corporate data. Somehow the user needs a means of being confident that the WAP he is connected to is a real one. And this is where certificates come into play.<\/p>\n\n\n\n<p>The protocol used to authenticate a user onto the network is called RADIUS, short for Remote Authentication Dial-In User Service. The reference to dial-in gives a clue as to how old it is, it dates back to the early days of the internet when a common means of connection was to dial in over a phone line. RADIUS allows for a centralised management of usernames and passwords to connect to networks. These days it is very commonly used to authenticate users onto wifi networks and an opensource implementation of RADIUS is the FreeRadius software package.<\/p>\n\n\n\n<p>I&#8217;m assuming that you are running a Linux server and that you have installed FreeRadius and got it to authenticate users onto your wifi network using a simple password. However, users with an android phone will have found recently that they can no longer connect because the option to ignore network credentials has been greyed out. This was a conscious decision by the android developers to try and improve overall network security but it has left a whole set of users and network administrators with non-functional network connections. Fortunately FreeRadius has all the tools to create and install self-signed certificates to get connected again. So, lets go&#8230;<\/p>\n\n\n\n<p>First this to do is go to the certificates directory on your FreeRadius server <\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>$ cd \/etc\/freeradius\/3.0\/certs<\/p>\n<\/blockquote>\n\n\n\n<p>There are all the tools you need in this directory. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Generating a CA certificate<\/h2>\n\n\n\n<p>You are going to generate a self signed Certification Authority (CA) certificate and then use it to generate a signed server certificate. Let&#8217;s start with the CA certificate.<\/p>\n\n\n\n<p>Look for the file <em>ca.cnf <\/em>in this directory and open it for editing<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>$ sudo nano ca.cnf<\/p>\n<\/blockquote>\n\n\n\n<p>Your now need to find the section that is describing your organisation<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>[certificate_authority]<br>countryName = FR<br>stateOrProvinceName = Radius<br>localityName = Somewhere<br>organizationName = Example Inc.<br>emailAddress = admin@example.org<br>commonName = &#8220;Example Certificate Authority&#8221;<\/p>\n<\/blockquote>\n\n\n\n<p>This is the default information and you will want to update it with your real data<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>[certificate_authority]<br>countryName = US<br>stateOrProvinceName = Wisconsin<br>localityName = Whitewater<br>organizationName = Purple Skyhooks Inc.<br>emailAddress = admin@purple-skyhooks.com<br>commonName = &#8220;Purple Skyhooks Certificate Authority&#8221;<\/p>\n<\/blockquote>\n\n\n\n<p>You will also want to choose a password for accessing this certificate for when you want to sign something and you need to add this into the password section of the ca.cnf file<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>[ req ]<br>prompt = no<br>distinguished_name = certificate_authority<br>default_bits = 2048<br>input_password = whatever<br>output_password = whatever<br>x509_extensions = v3_ca<\/p>\n<\/blockquote>\n\n\n\n<p>giving you something like<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>[ req ]<br>prompt = no<br>distinguished_name = certificate_authority<br>default_bits = 2048<br>input_password = hqa7ara4mcr@zqk3WNA<br>output_password = hqa7ara4mcr@zqk3WNA<br>x509_extensions = v3_ca<\/p>\n<\/blockquote>\n\n\n\n<p>Finally you may want to extend the life of your certificate by editing<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>default_days = 60<\/p>\n<\/blockquote>\n\n\n\n<p>To something more lengthy. Choose a period that balances security (short life) against convenience (long life). I tend to choose something like 400 days otherwise you will spend the whole of your life generating and distributing CA certificates.<\/p>\n\n\n\n<p>Now you are ready to generate your CA certificates<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>$ sudo make ca.pem<\/p>\n<\/blockquote>\n\n\n\n<p>This will generate a private key file <em>ca.key<\/em> and a public certificate file <em>ca.pem<\/em>. The private key file must remain private and secure and generally will not leave your server. It will be used to <em>sign <\/em>the server certificate that you will generate in the next step.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Generating a server certificate<\/h2>\n\n\n\n<p>Now we will edit the <em>server.cnf <\/em>in a similar way to describe our FreeRadius server. We start by modifying the [server] section to describe our radius server<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>[server]<br>countryName = US<br>stateOrProvinceName = Delaware <br>localityName = New Castle<br>organizationName = Grabitt Radius Services<br>emailAddress = dodgy_radius@grabbit-radius.com<br>commonName = &#8220;server1.grabbit-radius.com&#8221;<\/p>\n<\/blockquote>\n\n\n\n<p>The important attribute here is the <em>commonName <\/em>value which should be set to a fully qualified domain name FQDN. This name does not have to actually exist in the DNS but you will use it later when setting up your phone. But it makes sense to set it to something reasonable.<\/p>\n\n\n\n<p>You will also have to set up the password values and the <em>default-days <\/em>value to give the certificate a reasonable life. Same security\/convenience trade-off as above.<\/p>\n\n\n\n<p>Now generate the server certificate and key by typing<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>$ sudo make server.pem<\/p>\n<\/blockquote>\n\n\n\n<p>This will generate a private key file <em>server.key <\/em>and a certificate file <em>server.pem.<\/em><\/p>\n\n\n\n<p>The last thing to do is to change the ownership of the files to the freeradius user so that the radius server can read them<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>$ sudo chown freerad.freerad server.key server.pem ca.pem<\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\">Configuring the FreeRadius server<\/h2>\n\n\n\n<p>Now it&#8217;s time to tell the FreeRadius server about the certificates you&#8217;ve just generated. Go to the EAP module configuration file<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>$ cd ..\/mods-enabled<\/p>\n\n\n\n<p>$ sudo nano eap<\/p>\n<\/blockquote>\n\n\n\n<p>and find the <em>tls-config tls-common<\/em> section<\/p>\n\n\n\n<p>Edit the following lines<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>private_key_password = whatever<br>private_key_file = \/etc\/ssl\/private\/ssl-cert-snakeoil.key<\/p>\n<\/blockquote>\n\n\n\n<p>and change them to<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>private_key_password = &lt;the password you chose for server.cnf&gt;<br>private_key_file = ${certdir}\/server.key<\/p>\n<\/blockquote>\n\n\n\n<p>Then find the line<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>certificate_file = \/etc\/ssl\/certs\/ssl-cert-snakeoil.pem<\/p>\n<\/blockquote>\n\n\n\n<p>and replace it with<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>certificate_file = ${certdir}\/server.pem<\/p>\n<\/blockquote>\n\n\n\n<p>Find the line<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>ca_file = \/etc\/ssl\/certs\/ca-certificates.crt<\/p>\n<\/blockquote>\n\n\n\n<p>and replace it with<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>ca_file = ${certdir}\/ca.pem<\/p>\n<\/blockquote>\n\n\n\n<p>and save the file.<\/p>\n\n\n\n<p>You now need to restart the FreeRadius server <\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>$ sudo service freeradius restart<\/p>\n<\/blockquote>\n\n\n\n<p>and your WPA Enterprise wifi network will be running with a self-signed certificate. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Configuring your Android phones<\/h2>\n\n\n\n<h2 class=\"wp-block-heading\">Install the CA certificate<\/h2>\n\n\n\n<p>You phone now needs to be told to trust the certificate that the RADIUS server is presenting.  This is actually fairly simple except for the first part. You are about to encounter at first hand one of the most difficult parts of establishing a trusted connection. Somehow you have to get the <em>ca.pem<\/em> CA certificate onto your phone and you have to do it in a trusted fashion. There are several possible ways to do this:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Link your phone to your computer via a USB cable and transfer the file<\/li>\n\n\n\n<li>Write the certificate file to an SD card<\/li>\n\n\n\n<li>Use a trusted messaging service such as <em>Signal<\/em> or <em>WhatsApp<\/em> to transfer the file.<\/li>\n<\/ul>\n\n\n\n<p>Once you have it over to your phone go to your settings menu and select <\/p>\n\n\n\n<p>Security -&gt; Advanced -&gt; Encryption and Credentials -&gt; Install a certificate -&gt; Wi-Fi certificate<\/p>\n\n\n\n<p>All being well you will then be presented with a file chooser with your <em>ca.pem<\/em> in it. Select the file and give the certificate a name when asked by the pop-up. Choose something obvious like &#8220;Corporate Wifi&#8221;. Click on OK. You should get a message telling you that the certificate has been installed. Your phone will now trust certificates signed by your Certification Authority.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Connect to your wi-fi<\/h2>\n\n\n\n<p>Yes! We&#8217;re nearly there. <\/p>\n\n\n\n<p>Go your network configuration section and select the wi-fi section. You should see the wi-fi network you want displayed (assuming that the network side of things is all set up). Click on this network. You will be presented with a screen with a number of incomprehensible questions:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>For &#8220;EAP method&#8221; select &#8220;PEAP&#8221;<\/li>\n\n\n\n<li>For &#8220;Phase 2 authentication method&#8221; select &#8220;MSCHAPV2&#8221;<\/li>\n\n\n\n<li>For &#8220;CA certificate&#8221; select the name you gave the CA certificate above (&#8220;Corporate Wifi&#8221;)<\/li>\n\n\n\n<li>For &#8220;Domain&#8221; select the commonName value you set in the server.cnf file (&#8220;server1.grabbit-radius.com&#8221;).<\/li>\n\n\n\n<li>Fill in your username and password under &#8220;Identity&#8221; and &#8220;Password&#8221;.<\/li>\n\n\n\n<li>Press &#8220;Save&#8221;<\/li>\n<\/ul>\n\n\n\n<p>All being well you will connect securely to the wifi. Subsequent connections will be automatic.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Using FreeRadius to authenticate your WPA enterprise mobile users is comparatively easy especially if you use daloRadius to manage your users however setting up the certificates that you need for it to work with more recent android phones is poorly documented and if you only have a hazy idea of how certificates work can be [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":14,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-137","page","type-page","status-publish","hentry","post-preview"],"_links":{"self":[{"href":"https:\/\/www.titley.com\/index.php\/wp-json\/wp\/v2\/pages\/137","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.titley.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.titley.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.titley.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.titley.com\/index.php\/wp-json\/wp\/v2\/comments?post=137"}],"version-history":[{"count":8,"href":"https:\/\/www.titley.com\/index.php\/wp-json\/wp\/v2\/pages\/137\/revisions"}],"predecessor-version":[{"id":147,"href":"https:\/\/www.titley.com\/index.php\/wp-json\/wp\/v2\/pages\/137\/revisions\/147"}],"up":[{"embeddable":true,"href":"https:\/\/www.titley.com\/index.php\/wp-json\/wp\/v2\/pages\/14"}],"wp:attachment":[{"href":"https:\/\/www.titley.com\/index.php\/wp-json\/wp\/v2\/media?parent=137"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}