Difference between revisions of "FreeRadius EAP-TLS configuration"

From Alpine Linux
Jump to: navigation, search
Line 8: Line 8:
  
 
{{cmd|apk add freeradius freeradius-eap haveged}}
 
{{cmd|apk add freeradius freeradius-eap haveged}}
 +
 +
Haveged requires no configuration:
 +
{{cmd|service haveged start}}
 +
{{cmd|rc-update add haveged defaultu}}
  
 
= Certificates =
 
= Certificates =
Line 89: Line 93:
 
= Create the Diffie-Hellman file =
 
= Create the Diffie-Hellman file =
 
{{cmd|openssl dhparam -check -text -5 1024 -out /etc/raddb/certs/dh}}
 
{{cmd|openssl dhparam -check -text -5 1024 -out /etc/raddb/certs/dh}}
 +
 +
= /etc/raddb/clients.conf =
 +
 +
First we're going to add a client, this is your WiFi AP:
 +
 +
<pre>client home {
 +
    ipaddr = 192.168.1.10
 +
    proto = *
 +
    secret = <PASSWORD USED BY YOUR AP TO AUTHENTICATE WITH THIS RADIUS SERVER>
 +
    shortname = <YOUR_SSID>
 +
    require_message_authenticator = no
 +
    nas_type = other
 +
 +
    limit {
 +
        max_connections = 16
 +
        lifetime = 0
 +
        idle_timeout = 30
 +
    }
 +
}</pre>
 +
 +
= /etc/raddb/mods-available/eap =
 +
Next we configure eap. Note the + and - represent lines removed and added, don't include them in your config!
 +
 +
You're going to want to make these changes:
 +
 +
<pre>- default_eap_type = md5
 +
+ default_eap_type = tls</pre>
 +
 +
<pre>-  private_key_password = whatever
 +
+  private_key_password = <Password you set output_password in server.cnf>
 +
    private_key_file = ${certdir}/server.pem</pre>
 +
 +
<pre>-  ca_file = ${cadir}/ca.pem
 +
+  ca_file = ${cadir}/cacrl.pem</pre>
 +
 +
<pre>-  random_file = /dev/urandom
 +
+  random_file = /dev/random</pre>
 +
 +
<pre>- # check_crl = yes               
 +
+  check_crl = yes</pre>
 +
 +
 +
Reduce cipher list from DEFAULT to HIGH, or even a specific list:
 +
<pre>-  cipher_list = "DEFAULT"
 +
+  #cipher_list = "HIGH"</pre>
 +
 +
Or a shorter list
 +
<pre>+  cipher_list = "ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-CAMELLIA256-SHA:DHE-RSA-CAMELLIA128-SHA"</pre>
 +
 +
Change ecdh curve to something stronger:
 +
<pre>-  ecdh_curve = "prime256v1"
 +
+  ecdh_curve = "secp384r1"</pre>
 +
 +
These all worked with Android 4.4.4, but if you have older stuff you may need to set the list to HIGH or DEFAULT.
 +
 +
Couple of other things to change:
 +
 +
<pre>-    #name = "EAP module"
 +
+    name = "EAP-TLS"</pre>
 +
 +
<pre>-    #persist_dir = "${logdir}/tlscache"
 +
+    persist_dir = "${logdir}/tlscache"</pre>
 +
 +
= /etc/raddb/mods-config/files/authorize =
 +
<pre>+First_Android_Phone
 +
+Other_Android_Phone
 +
+Other_Linux_Laptop
 +
+           
 +
+DEFAULT    Auth-type := Reject
 +
+          Reply-Message := "Access Denied! Authorized users only."</pre>
  
 
= References =
 
= References =
 
* https://forums.freebsd.org/threads/howto-wpa2-enterprise-with-freeradius.28467
 
* https://forums.freebsd.org/threads/howto-wpa2-enterprise-with-freeradius.28467
 
* https://samhobbs.co.uk/2013/12/remove-network-may-be-monitored-by-an-unknown-third-party-in-android-4-4-kitkat
 
* https://samhobbs.co.uk/2013/12/remove-network-may-be-monitored-by-an-unknown-third-party-in-android-4-4-kitkat

Revision as of 14:00, 12 July 2015

Introduction

A more secure way than using pre-shared keys (WPA2) is to use EAP-TLS and use separate certificates for each device. In the previous tutorial Linux Router with VPN on a Raspberry Pi I mentioned I'd be doing this with a (Ubiquiti UniFi AP). I have tested this with two phones running CyanogenMod 11 (Android 4.4.4).

Installation

Install freeradius and haveged. You'll need haveged to increase randomness of /dev/random Entropy and randomness. When feature 3465 is resolved if you have a Raspberry Pi you could use it's own hardware random number generator (bcm2708-rng).

apk add freeradius freeradius-eap haveged

Haveged requires no configuration:

service haveged start

rc-update add haveged defaultu

Certificates

You will want to create your certificates. The easiest way to do that is to use the scripts provided by FreeRadius. The scripts allow you to easily create a CA (certificate authority), Server certificate, and Client certificates. Remember to increase the expiry time from 60 days if that doesn't suit you and fill in the other information in the .cnf files like the README says.

The readme for that script is in /etc/raddb/certs/README or can be found here.

Certificate Revocation List

The CRL is not created by the script, you have to do that one manually.

I created a file called crl.cnf:

[ ca ]
default_ca		= CA_default

[ CA_default ]
dir			= ./
certs			= $dir
crl_dir			= $dir/crl
database		= $dir/index.txt
new_certs_dir		= $dir
certificate		= $dir/ca.pem
serial			= $dir/serial
crl			= $dir/crl.pem
private_key		= $dir/ca.key
RANDFILE		= $dir/.rand
name_opt		= ca_default
cert_opt		= ca_default
default_days		= 730
default_crl_days	= 730
default_md		= sha256
preserve		= no
policy			= policy_match
crlDistributionPoints	= URI:http://www.example.com/example_ca.crl

[ policy_match ]
countryName		= match
stateOrProvinceName	= match
organizationName	= match
organizationalUnitName	= optional
commonName		= supplied
emailAddress		= optional

[ policy_anything ]
countryName		= optional
stateOrProvinceName	= optional
localityName		= optional
organizationName	= optional
organizationalUnitName	= optional
commonName		= supplied
emailAddress		= optional

[ req ]
prompt			= no
distinguished_name	= cacrl
default_bits		= 2048
input_password		= <password1>
output_password		= <password2>
x509_extensions		= v3_ca

[certificate_authority]
countryName		= <COUNTRY_CODE>
stateOrProvinceName	= Radius
localityName		= <REGION>
organizationName	= FreeRadius
emailAddress		= freeradius@localhost 
commonName		= "FreeRadius Certificate Authority"

[v3_ca]
subjectKeyIdentifier	= hash
authorityKeyIdentifier	= keyid:always,issuer:always
basicConstraints	= CA:true
crlDistributionPoints	= URI:http://www.example.com/example_ca.crl

Create the revocation list:

openssl ca -gencrl -keyfile ca.key -cert ca.pem -out crl.pem -config crl.cnf

Finally, create new file which will hold both CA and revoked certificates:

cat ca.pem crl.pem > cacrl.pem

Create the Diffie-Hellman file

openssl dhparam -check -text -5 1024 -out /etc/raddb/certs/dh

/etc/raddb/clients.conf

First we're going to add a client, this is your WiFi AP:

client home {
    ipaddr = 192.168.1.10
    proto = *
    secret = <PASSWORD USED BY YOUR AP TO AUTHENTICATE WITH THIS RADIUS SERVER>
    shortname = <YOUR_SSID>
    require_message_authenticator = no
    nas_type = other

    limit {
        max_connections = 16
        lifetime = 0
        idle_timeout = 30
    }
}

/etc/raddb/mods-available/eap

Next we configure eap. Note the + and - represent lines removed and added, don't include them in your config!

You're going to want to make these changes:

- default_eap_type = md5
+ default_eap_type = tls
-   private_key_password = whatever
+   private_key_password = <Password you set output_password in server.cnf>
    private_key_file = ${certdir}/server.pem
-   ca_file = ${cadir}/ca.pem
+   ca_file = ${cadir}/cacrl.pem
-   random_file = /dev/urandom
+   random_file = /dev/random
- # check_crl = yes                 
+   check_crl = yes


Reduce cipher list from DEFAULT to HIGH, or even a specific list:

-   cipher_list = "DEFAULT"
+   #cipher_list = "HIGH"

Or a shorter list

+   cipher_list = "ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-CAMELLIA256-SHA:DHE-RSA-CAMELLIA128-SHA"

Change ecdh curve to something stronger:

-   ecdh_curve = "prime256v1"
+   ecdh_curve = "secp384r1"

These all worked with Android 4.4.4, but if you have older stuff you may need to set the list to HIGH or DEFAULT.

Couple of other things to change:

-     #name = "EAP module"
+     name = "EAP-TLS"
-     #persist_dir = "${logdir}/tlscache"
+     persist_dir = "${logdir}/tlscache"

/etc/raddb/mods-config/files/authorize

+First_Android_Phone
+Other_Android_Phone
+Other_Linux_Laptop
+            
+DEFAULT    Auth-type := Reject
+           Reply-Message := "Access Denied! Authorized users only."

References