Connessione PPP seriale tra Windows 2000/XP e Linux con autenticazione EAP-TLS

In questo documento viene spiegato come creare una connessione PPP tra una macchina Windows 2000/XP e una Linux utilizzando un cavo null-modem ed effettuando autenticazione EAP-TLS.

Introduzione

Verrano ora descritti i protocolli utilizzati, le applicazioni che li implementano e il procedimento utilizzato per effettuare la connessione.

Protocolli

PPP (Point to Point Protocol) [PPP] è un protocollo di livello 2 che permette di trasportare pacchetti di diversi protocolli di rete attraverso collegamenti punto-punto.
PPP gestisce tre aspetti della connessione punto-punto:

Una connessione PPP evolve passando attraverso varie fasi che sono mostrate dal seguente schema:

   +------+        +-----------+           +--------------+
   |      | UP     |           | OPENED    |              | SUCCESS/NONE
   | Dead |------->| Establish |---------->| Authenticate |--+
   |      |        |           |           |              |  |
   +------+        +-----------+           +--------------+  |
      ^               |                        |             |
      |          FAIL |                   FAIL |             |
      +<--------------+             +----------+             |
      |                             |                        |
      |            +-----------+    |           +---------+  |
      |       DOWN |           |    |   CLOSING |         |  |
      +------------| Terminate |<---+<----------| Network |<-+
                   |           |                |         |
                   +-----------+                +---------+
Tra le fasi è presente anche una opzionale di autenticazione che, utilizzando il meccanismo scelto nella fase 'Establish' attraverso LCP, permette di verificare l'identità del peer. I protocolli di autenticazione standardizzati sono PAP, CHAP e EAP

EAP (Extensible Authentication Protocol) [EAP] è un protocollo che permette di 'trasportare' diversi metodi di autenticazione.
EAP viene utilizzato direttamente sopra livelli data-link come PPP o IEEE 802 e non richiede quindi un protocollo di rete come IP. EAP è un protocollo 'lock-step' (un solo pacchetto può essere in transito in un dato momento) e fornisce supporto per la ritrasmissione e l'eliminazione dei duplicati, ma non quello per la frammentazione (che può però essere implementata da uno specifico metodo EAP).
Inoltre EAP prevede la possibilità di utilizzare un 'Backend Authentication Server' che implementa i vari metodi di autenticazione (tipicamente un server RADIUS).
La conversazione EAP prevede che l'autenticatore invii un pacchetto di richiesta EAP; il pacchetto contiene un campo Type che specifica il tipo di richiesta ed eventualmente dei dati. Il peer invia quindi un pacchetto di risposta EAP col medesimo valore di Type e con i dati relativi.
Questo scambio viene ripetuto più volte fino a quando l'autenticazione è terminata e l'autenticatore invia un pacchetto EAP Success o EAP Failure.
Ogni implementazione EAP deve riconoscere i seguenti valori del campo Type:

  1. Identity : usato per richiedere l'identità del peer. E' tipicamente il primo pacchetto scambiato, ma può non essere utilizzato quando l'identità remota è nota a priori.
  2. Notification : usato dall'autenticatore per trasmettere al peer un messaggio da mostrare all'utente o da registrare nei log.
  3. Nak (Response only) : dichiara un rifiuto da parte dell'autenticato di utilizzare il metodo di autenticazione richiesto; permette di specificare uno o più metodi alternativi.
  4. MD5-Challenge : permette di effettuare autenticazione attraverso il metodo EAP-MD5 che è sostanzialmente un'autenticazione CHAP [CHAP] per mezzo di pacchetti EAP.

TLS (Transport Layer Security) [TLS] è un protocollo che permette comunicazioni sicure tra 2 applicazioni agendo tra il livello di trasporto e quello delle applicazioni.
Il protocollo è stratificato su 2 livelli: a livello inferiore il TLS Record Protocol si appoggia direttamente ad un livello di trasporto affidabile come TCP e ha il compito di incapsulare i messaggi dei protocolli di livello superiore garantendo segretezza e autenticità dei dati attraverso crittografia simmetrica e funzioni di hash.
Un protocollo ad un livello superiore è il TLS Handshake Protocol che permette l'autenticazione reciproca tra client e server, la negoziazione di algoritmi e la generazione di chiavi di sessione.
Altri protocolli TLS sono l'Alert Protocol che gestisce la segnalazione di errori e il Change Cipher Spec protocol che segnala il passaggio al nuovo stato negoziato.

EAP-TLS [EAP-TLS] è un metodo di autenticazione EAP basato sull'incapsulamento di messaggi dell'hanshake TLS in pacchetti EAP; permette l'autenticazione reciproca, la negoziazione di un insieme di algoritmi e la generazione di chiavi di sessione.
Una tipica conversazione EAP-TLS che ha successo avviene secondo il seguente schema:

    Autenticato             Autenticatore
    -----------             -------------
                           <- PPP EAP-Request/
                           Identity
   PPP EAP-Response/
   Identity (MyID) ->
                           <- PPP EAP-Request/
                           EAP-Type=EAP-TLS
                           (TLS Start)
   PPP EAP-Response/
   EAP-Type=EAP-TLS
   (TLS client_hello)->
                           <- PPP EAP-Request/
                           EAP-Type=EAP-TLS
                           (TLS server_hello,
                            TLS certificate,
                    [TLS server_key_exchange,]
                    [TLS certificate_request,]
                        TLS server_hello_done)
   PPP EAP-Response/
   EAP-Type=EAP-TLS
   (TLS certificate,
    TLS client_key_exchange,
   [TLS certificate_verify,]
    TLS change_cipher_spec,
    TLS finished) ->
                           <- PPP EAP-Request/
                           EAP-Type=EAP-TLS
                           (TLS change_cipher_spec,
                            TLS finished)
   PPP EAP-Response/
   EAP-Type=EAP-TLS ->
                           <- PPP EAP-Success

Come si può notare, l'autenticatore invia una richiesta di tipo Identity e il peer comunica la propria identità (come già detto questo scambio può non avvenire).
Quindi il sever invia un pacchetto di tipo EAP-TLS con il bit di Start. A questo punto i pacchetti scambiati contengono i messaggi relativi all'handshake TLS. Quando infine l'handshake è terminato con successo l'autenticatore invia un pacchetto EAP Success.
Si può notare anche che durante l'handshake vengono scambiati i certificati dei due peer; i certificati possono raggiungere anche grandi dimensioni e non di rado superano l'MTU per il link PPP. E' quindi previsto in EAP-TLS un meccanismo per gestire la frammentazione; questo meccanismo si basa su alcuni bit contenuti nel campo Flags del pacchetto EAP-TLS.
      Flags

      0 1 2 3 4 5 6 7 8
      +-+-+-+-+-+-+-+-+
      |L M S R R R R R|
      +-+-+-+-+-+-+-+-+

      L = Length included
      M = More fragments
      S = EAP-TLS start
      R = Reserved
Oltre al bit EAP-TLS Start che serve a iniziare la conversazione come già visto in precedenza, i due bit che gestiscono la frammentazione sono i seguenti: Quando l'autenticatore deve inviare un pacchetto frammentato, invia il primo frammento, ponendo a 1 i bit L e M e specificando la dimensione totale del messaggio nel campo TLS Message Length, in modo da facilitare l'allocazione della memoria nel peer. Il peer risponde quindi con un Ack cioè con un messaggio EAP-TLS senza dati. L'autenticatore invia i frammenti successivi e il peer risponde sempre con un Ack. Infine quando l'autenticatore deve inviare l'ultimo frammento, lascia a 0 il bit M. Quando il peer riceve questo pacchetto sa che il messaggio originale può essere ricostruito e quindi invia la risposta. Lo stesso meccanismo avviene anche nel senso opposto cioè quando il peer deve inviare un pacchetto frammentato.
Il formato di un pacchetto EAP-TLS è il seguente:
  0                   1                   2                   3
   0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |     Code      |   Identifier  |            Length             |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |     Type      |     Flags     |      TLS Message Length
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
         TLS Message Length        |       TLS Data...
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Il campo TLS Message Length può non essere presente.

Procedimento

Lo scopo è quello di realizzare una connessione attraverso le porte seriali di un calcolatore Linux e di uno Windows connessi con cavo null-modem e di utilizzare come autenticazione EAP-TLS.

In Windows 2000 e Windows XP è presente una implementazione PPP che supporta EAP-TLS solo in modalità client.

Il demone PPP per Linux [LINUX-PPP] nella versione attualmente più recente (2.4.3) supporta EAP, ma solo nei metodi MD5 e SRP. Per usare EAP-TLS è quindi necessario installare la patch apposita [PATCH].

Verrà quindi usato Linux come autenticatore e Windows come client.

La prima fase consiste nella creazione dei certificati necessari: lo scenario è quello di un utente ("mike") sul client che si connette al server ("serv1.in.testlab"), quindi sono necessari questi due certificati, oltre a quello della CA e delle chiavi private.

Quindi verrà mostrata la procedura necessaria per configurare la connessione sui 2 host. Infine sarà mostrato l'ouput e l'analisi della fase di autenticazione.

Certificati

In questo capitolo viene spiegato come generare i certificati necessari all'autenticazione TLS. In particolare dovremo creare prima una Certification Authority (CA) e in seguito 2 certificati firmati dalla CA: uno per l'utente e uno per il server.
Il software usato è OpenSSL [OPENSSL]

Creazione della CA

Per generare la chiave privata e il certificato della CA verrà utilizzato lo script CA fornito con OpenSSL. Normalmente lo script non si trova nel path di esecuzione, quindi bisogna specificare il percorso completo che però varia a seconda dell'installazione. Nel caso considerato OpenSSL è installato in /usr/share/ssl quindi il percorso dello script CA è /usr/share/ssl/misc/CA
Per generare una nuova CA si usa l'opzione -newca. Verrà chiesta una pass phrase per proteggere la chiave privata della CA e in seguito i dati relativi alla Certification Authority stessa.
$ /usr/share/ssl/misc/CA -newca
CA certificate filename (or enter to create)

Making CA certificate ...
Generating a 1024 bit RSA private key
........++++++
...........++++++
writing new private key to './demoCA/private/./cakey.pem'
Enter PEM pass phrase:
Verifying - Enter PEM pass phrase:
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [IT]:
State or Province Name (full name) []:
Locality Name (eg, city) []:
Organization Name (eg, company) []:testlab
Organizational Unit Name (eg, section) []:Certification Authority
Common Name (eg, your name or your server's hostname) []:testlab CA
Email Address []:
$
A questo punto la chiave privata della CA è stata salvata in ./demoCA/private/cakey.pem cifrata con la pass phrase inserita, mentre il certificato della CA in ./demoCA/cacert.pem.

Creazione del certificato utente

Verrà ora creato il certificato per l'utentè. Questo certificato, per poter essere importato in Windows e utilizzato nell'autenticazione EAP-TLS deve contenere la seguente estensione:

extendedKeyUsage=1.3.6.1.5.5.7.3.2

che corrisponde a "TLS Web Client Authentication". Affinchè questa estensione venga inserita dalla CA quando firma il certificato bisogna modificare il file di configurazione di OpenSSL, in questo caso /usr/share/ssl/openssl.cnf inserendo nella sezione [usr_cert] la riga extendedKeyUsage=1.3.6.1.5.5.7.3.2

[ usr_cert ]
# These extensions are added when 'ca' signs a request.
basicConstraints=CA:FALSE
extendedKeyUsage=1.3.6.1.5.5.7.3.2
Procediamo con la creazione della chiave privata dell'utente mike usando il comando openssl genrsa:
$ openssl genrsa -out mike.key 1024
Generating RSA private key, 1024 bit long modulus
..............++++++
..............................................++++++
e is 65537 (0x10001)
La chiave privata generata ha una lunghezza di 1024 bit ed è stata salvata in chiaro nel file mike.key. Il passo seguente consiste nel creare una richiesta di certificato per mike. Utilizziamo il comando 'openssl req' specificando la chiave privata appena creata:
$ openssl req -new -key mike.key -out newreq.pem
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [IT]:
State or Province Name (full name) []:
Locality Name (eg, city) []:
Organization Name (eg, company) []:testlab
Organizational Unit Name (eg, section) []:
Common Name (eg, your name or your server's hostname) []:mike
Email Address []:

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
$
Infine è necessario che la CA firmi la richiesta di certificato per mike; viene utilizzato ancora lo script CA con l'opzione -sign :
$ /usr/share/ssl/misc/CA -sign
Using configuration from /usr/share/ssl/openssl.cnf
Enter pass phrase for ./demoCA/private/cakey.pem:
Check that the request matches the signature
Signature ok
Certificate Details:
        Serial Number: 1 (0x1)
        Validity
            Not Before: Mar 10 15:16:37 2005 GMT
            Not After : Mar 10 15:16:37 2006 GMT
        Subject:
            countryName               = IT
            organizationName          = testlab
            commonName                = mike
        X509v3 extensions:
            X509v3 Basic Constraints:
            CA:FALSE
            X509v3 Extended Key Usage:
            TLS Web Client Authentication
            Netscape Comment:
            OpenSSL Generated Certificate
            X509v3 Subject Key Identifier:
            9B:EB:C5:36:3A:5D:03:8B:A6:EC:28:68:B7:D3:FC:4A:73:3D:FD:E1
            X509v3 Authority Key Identifier:
            keyid:AD:EA:34:DA:60:9D:FC:CF:82:8A:5C:4A:F6:46:D3:0C:BA:8A:19:45
            DirName:/C=IT/O=testlab/OU=Certification Authority/CN=testlab CA
            serial:00

Certificate is to be certified until Mar 10 15:16:37 2006 GMT (365 days)
Sign the certificate? [y/n]:y


1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries
Data Base Updated
Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number: 1 (0x1)
        Signature Algorithm: md5WithRSAEncryption
        Issuer: C=IT, O=testlab, OU=Certification Authority, CN=testlab CA
        Validity
            Not Before: Mar 10 15:16:37 2005 GMT
            Not After : Mar 10 15:16:37 2006 GMT
        Subject: C=IT, O=testlab, CN=mike
        Subject Public Key Info:
            Public Key Algorithm: rsaEncryption
            RSA Public Key: (1024 bit)
                Modulus (1024 bit):
                    00:b0:9b:ae:1c:e2:bf:59:09:8d:bb:18:f1:a9:43:
                    ce:fb:68:52:99:9c:dc:14:83:ab:c5:77:00:11:d2:
                    07:55:6a:ed:4c:2f:d6:8c:10:71:89:33:94:cf:64:
                    f4:21:4c:53:a9:cf:01:c2:a0:e0:72:51:c7:5f:3d:
                    f8:06:ea:87:74:41:b2:16:2a:0e:53:2f:89:16:f3:
                    7e:ca:21:ae:1f:d5:5a:06:ce:8f:5a:b9:b3:e7:c0:
                    d0:e8:ea:9d:b2:70:d6:06:18:43:a2:7d:78:46:8b:
                    ef:b6:66:8d:05:aa:10:b3:fe:77:27:3c:e5:ec:39:
                    e8:2a:d6:37:30:de:1f:5a:e5
                Exponent: 65537 (0x10001)
        X509v3 extensions:
            X509v3 Basic Constraints:
            CA:FALSE
            X509v3 Extended Key Usage:
            TLS Web Client Authentication
            Netscape Comment:
            OpenSSL Generated Certificate
            X509v3 Subject Key Identifier:
            9B:EB:C5:36:3A:5D:03:8B:A6:EC:28:68:B7:D3:FC:4A:73:3D:FD:E1
            X509v3 Authority Key Identifier:
            keyid:AD:EA:34:DA:60:9D:FC:CF:82:8A:5C:4A:F6:46:D3:0C:BA:8A:19:45
            DirName:/C=IT/O=testlab/OU=Certification Authority/CN=testlab CA
            serial:00

    Signature Algorithm: md5WithRSAEncryption
        93:10:a9:03:d6:a3:7b:e1:53:4f:34:d3:0b:9a:b7:01:79:42:
        6c:98:60:ca:6c:0e:e4:94:e5:2f:43:62:1c:1b:a9:45:ac:a2:
        5e:7f:ad:0e:91:56:ec:88:7f:6f:a3:17:97:8e:75:e6:51:06:
        ef:58:8a:9e:25:81:0b:0b:cd:eb:d1:a4:fb:3f:d9:b4:1f:d4:
        8a:4a:1a:97:02:9f:4b:30:75:7a:66:2e:1d:ba:bd:e1:a2:aa:
        c2:cb:e3:5c:f4:0a:13:10:0b:a4:6f:c2:e2:4c:61:e4:f4:0b:
        15:ce:74:7d:9a:0c:56:10:b2:91:b7:bc:5c:2d:e1:b0:6e:88:
        ae:fc
-----BEGIN CERTIFICATE-----
MIIC6zCCAlSgAwIBAgIBATANBgkqhkiG9w0BAQQFADBWMQswCQYDVQQGEwJJVDEQ
MA4GA1UEChMHdGVzdGxhYjEgMB4GA1UECxMXQ2VydGlmaWNhdGlvbiBBdXRob3Jp
dHkxEzARBgNVBAMTCnRlc3RsYWIgQ0EwHhcNMDUwMzEwMTUxNjM3WhcNMDYwMzEw
MTUxNjM3WjAuMQswCQYDVQQGEwJJVDEQMA4GA1UEChMHdGVzdGxhYjENMAsGA1UE
AxMEbWlrZTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAsJuuHOK/WQmNuxjx
qUPO+2hSmZzcFIOrxXcAEdIHVWrtTC/WjBBxiTOUz2T0IUxTqc8BwqDgclHHXz34
BuqHdEGyFioOUy+JFvN+yiGuH9VaBs6PWrmz58DQ6OqdsnDWBhhDon14RovvtmaN
BaoQs/53Jzzl7DnoKtY3MN4fWuUCAwEAAaOB8DCB7TAJBgNVHRMEAjAAMBMGA1Ud
JQQMMAoGCCsGAQUFBwMCMCwGCWCGSAGG+EIBDQQfFh1PcGVuU1NMIEdlbmVyYXRl
ZCBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQUm+vFNjpdA4um7Chot9P8SnM9/eEwfgYD
VR0jBHcwdYAUreo02mCd/M+CilxK9kbTDLqKGUWhWqRYMFYxCzAJBgNVBAYTAklU
MRAwDgYDVQQKEwd0ZXN0bGFiMSAwHgYDVQQLExdDZXJ0aWZpY2F0aW9uIEF1dGhv
cml0eTETMBEGA1UEAxMKdGVzdGxhYiBDQYIBADANBgkqhkiG9w0BAQQFAAOBgQCT
EKkD1qN74VNPNNMLmrcBeUJsmGDKbA7klOUvQ2IcG6lFrKJef60OkVbsiH9voxeX
jnXmUQbvWIqeJYELC83r0aT7P9m0H9SKShqXAp9LMHV6Zi4dur3hoqrCy+Nc9AoT
EAukb8LiTGHk9AsVznR9mgxWELKRt7xcLeGwboiu/A==
-----END CERTIFICATE-----
Signed certificate is in newcert.pem
$
In questo modo il certificato è stato creato e salvato nel file newcert.pem. Come si può verificare è presente l'estensione 'TLS Web Client Authentication'. Ora rinominiamo il file newcert.pem in mike.pem e infine creiamo un file contenente il certificato di mike, la sua chiave privata e il certificato della CA. Questo file in formato PKCS12 potrà poi essere importato sul client Windows.
$ mv newcert.pem mike.pem
$ openssl pkcs12 -export -in mike.pem -inkey mike.key -certfile demoCA/cacert.pem 
  -out mike.p12
Enter Export Password:
Verifying - Enter Export Password:
$

Creazione del certificato per il server

Il procedimento è simile a quello mostrato per il certificato utente. L'unica differenza sta nel fatto che bisogna modificare di nuovo il file di configurazione di OpenSSL cambiando la riga precedemente aggiunta in: extendedKeyUsage=1.3.6.1.5.5.7.3.1 , che corrisponde a "TLS Web Server Authentication"
[ usr_cert ]
# These extensions are added when 'ca' signs a request.
basicConstraints=CA:FALSE
extendedKeyUsage=1.3.6.1.5.5.7.3.1
A parte questo la procedura è del tutto analoga e prevede i seguenti comandi:
$ openssl genrsa -out serv1.in.testlab.key 1024
$ openssl req -new -key serv1.in.testlab.key -out
$ /usr/share/ssl/misc/CA -sign
$ mv newcert.pem serv1.in.testlab.pem
Il certificato prodotto è il seguente
Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number: 2 (0x2)
        Signature Algorithm: md5WithRSAEncryption
        Issuer: C=IT, O=testlab, OU=Certification Authority, CN=testlab CA
        Validity
            Not Before: Mar 10 15:25:57 2005 GMT
            Not After : Mar 10 15:25:57 2006 GMT
        Subject: C=IT, O=testlab, CN=serv1.in.testlab
        Subject Public Key Info:
            Public Key Algorithm: rsaEncryption
            RSA Public Key: (1024 bit)
                Modulus (1024 bit):
                    00:a4:d9:4c:e5:ff:9a:b1:16:36:66:3e:7c:15:dc:
                    8f:b8:cc:5b:28:6e:d3:4f:12:57:41:18:5b:8b:6b:
                    2e:7e:69:8a:6e:a9:6a:14:34:d0:3a:0d:d9:b4:83:
                    23:b9:2f:8f:db:56:f9:97:7e:77:ec:c6:a0:4e:eb:
                    90:33:67:d9:a1:70:6f:2d:dc:49:17:f6:0d:0b:ff:
                    94:5f:53:a7:11:f1:5e:28:d1:19:c6:e5:37:83:89:
                    cb:2b:dc:1d:9c:16:30:6b:00:02:19:29:fe:e0:1b:
                    5e:36:d9:47:dd:8c:09:58:d7:c4:68:a9:06:d1:74:
                    42:ca:b3:7e:17:5e:34:01:4f
                Exponent: 65537 (0x10001)
        X509v3 extensions:
            X509v3 Basic Constraints:
            CA:FALSE
            X509v3 Extended Key Usage:
            TLS Web Server Authentication
            Netscape Comment:
            OpenSSL Generated Certificate
            X509v3 Subject Key Identifier:
            35:94:52:A4:82:4B:32:4A:D4:F7:3E:CF:2C:AD:15:25:46:A6:E6:3D
            X509v3 Authority Key Identifier:
            keyid:AD:EA:34:DA:60:9D:FC:CF:82:8A:5C:4A:F6:46:D3:0C:BA:8A:19:45
            DirName:/C=IT/O=testlab/OU=Certification Authority/CN=testlab CA
            serial:00

    Signature Algorithm: md5WithRSAEncryption
        9e:d0:5a:87:4e:1e:c9:81:9d:11:e7:69:52:36:04:a4:e8:11:
        45:a4:79:b1:78:fc:cb:58:1b:42:83:00:98:a0:aa:96:3c:5d:
        6c:48:b9:39:3a:0c:b0:d3:bc:1c:88:ce:2e:a2:ac:78:33:e3:
        9b:ee:2a:51:5e:5c:cd:69:19:6a:99:c0:1e:ab:61:15:58:67:
        19:88:b4:34:5f:1f:18:8e:81:cb:64:30:07:35:58:2f:61:5e:
        d0:3b:df:9a:57:33:13:21:f3:af:2f:ca:8f:af:b7:1b:8f:85:
        0e:8a:27:fa:c9:40:3d:8d:0f:0e:af:6f:63:28:de:4d:f1:18:
        1c:0a
In questo caso non c'è necessità di creare l'archivio PKCS12.

Installazione dei certificati

A questo punto bisogna trasferire il file mike.p12 sulla macchina Windows e installarlo come mostrato in seguito.
Per quanto riguarda il server, è necessario copiare in una directory sul server il certificato del server, la sua chiave privata e il certificato della CA. In questo caso è stato usato come server la stessa macchina sulla quale sono stati generati i certificati; sono stati copiati i certificati nella directory /root/cert
$ mkdir /root/cert
$ cp serv1.in.testlab.pem serv1.in.testlab.key demoCA/cacert.pem /root/cert

Setup Linux

Ora verrà spiegato come impostare la macchina Linux in modo da rendere operativo il server pppd.
Va tenuto presente che alcune delle operazioni descritte richiedono i privilegi di root.

Compilazione

Prima di tutto è necessario scaricare i sorgenti del programma ppp-2.4.3 e la patch per EAP-TLS.
$ wget ftp://ftp.samba.org/pub/ppp/ppp-2.4.3.tar.gz
$ wget http://eaptls.spe.net/download/ppp-2.4.3-eaptls-0.7.patch
Estrarre i file dall'archivio e applicare la patch:
$ tar -xzf ppp-2.4.3.tar.gz
$ cd ppp-2.4.3
$ patch -p1 < ../ppp-2.4.3-eaptls-0.7.patch
patching file etc.ppp/eaptls-client
patching file etc.ppp/eaptls-server
patching file linux/Makefile.top
patching file pppd/auth.c
patching file pppd/eap.c
patching file pppd/eap.h
patching file pppd/eap-tls.c
patching file pppd/eap-tls.h
patching file pppd/main.c
patching file pppd/Makefile.linux
patching file pppd/options.c
patching file pppd/pathnames.h
patching file pppd/pppd.h
patching file README.eap-tls
patching file solaris/Makefile.top
$
Va poi compilato e installato il programma:
$ ./configure
$ make
$ make install
$ make install-etcppp

Configurazione

Ora bisogna modificare i file di configurazione di pppd per permettere al client 'mike' l'accesso con autenticazione EAP-TLS. Il file che contiene tali informazioni è /etc/ppp/eaptls-server; ad esso aggiungiamo la seguente riga:
# Parameters for authentication using EAP-TLS (server)

# client name (can be *)
# server name (can be *)
# client certificate file (optional, if unused put '-')
# server certificate file (required)
# CA certificate file (required)
# server private key file (required)
# allowed addresses (required, can be *)

#client server  -       /root/cert/server.crt   /root/cert/ca.crt
/root/cert/server.key   192.168.1.0/24

mike  serv1.in.testlab  -  /root/cert/serv1.in.testlab.pem
 /root/cert/cacert.pem   /root/cert/serv1.in.testlab.key    192.168.10.3
E' importante che i 7 token siano separati fra loro da una tabulazione e che resti tutto sulla stessa riga.
La riga aggiunta specifica che l'utente 'mike' è autorizzato all'accesso previa autenticazione EAP-TLS e vengono definiti i parametri necessari: il certificato che il server deve usare, la chiave privata per quel certificato, il file con i certificati delle CA e gli indirizzi IP permessi alla macchina remota.
Ora non resta che lanciare pppd con il seguente comando:
$ pppd /dev/ttyS0 115200 nodetach auth name serv1.in.testlab debug 
   record conn.rec 192.168.10.2:192.168.10.3
Le opzioni usate sono le seguenti:

Setup Windows

Verrà spiegato il procedimento per effettuare una connessione ppp con autenticazione EAP-TLS con Windows 2000/XP.

Importazione dei certificati

Per poter usare l'autenticazione EAP-TLS è necessario avere installato dei certificati validi. Verrà utilizzato il certificato per l'utente 'mike' precedentemente creato e la chiave privata relativa, insieme al file della CA.
Per importare in Windows i certificati è sufficiente aprire il file mike.p12 precedentemente creato. Viene quindi avviata l'importazione guidata dei certificati che chiederà la password usata per cifrare la chiave privata. Infine verrà chiesto di confermare se vogliamo aggiungere 'testlab CA' all'archivio delle CA attendibili.

Creazione della connessione

Per creare la nuova connessione bisogna aprire il pannello di controllo, quindi 'Connessioni di rete' e cliccare su 'Crea una nuova connessione'.
Si giunge quindi ad un dialog che chiede che tipo di connessione creare; va selezionato 'Installazione di una connessione avanzata'.

 

Tipo di connessione

 

Confermare e nel dialog successivo selezionare 'Connetti direttamente ad un altro computer'.

 

 

Nella finestra seguente selezionare Guest. Nella finestra seguente bisogna inserire il nome da dare alla connessione

 

 

Infine viene chiesto quale porta seriale va utilizzata; nel nostro caso COM2.

 

 

La connessione è stata ora creata. Bisogna quindi impostarne i parametri selezionando le proprietà della connessione creata.
Nella sezione 'Generale' bisogna cliccare su configura e impostare la velocità della porta a 115200 bps.

 

 

Nella sezione 'Protezione' scegliere 'Avanzate' e quindi cliccare su Impostazioni:

 

 

Scegliere 'crittografia facoltativa','Utilizza EAP','Smart Card o altro certificato' e quindi cliccare su proprietà.

 

 

Nella finestra 'Proprietà smart card o altro certificato' selezionare 'Utilizza certificato su questo computer', 'Convalida certificato server', 'Connetti solo se il nome del server termina in' e inserire 'serv1.in.testlab'.
Scegliere come Autorità di certificazione attendibile 'testlab CA'.

 

 

A questo punto la connessione è stata impostata configurata e può essere effettuata aprendo l'icona 'serv1.in.testlab' nelle finestra 'Connessioni di rete'; è quindi necessario selezionare il certificato utente da utilizzare, in questo caso quello relativo a 'mike'.

 

 

Infine ha inizio la connessione

 

 

Output della connessione

Output di pppd su Linux:
using channel 5
Using interface ppp0
Connect: ppp0 <--> /dev/pts/0
sent [LCP ConfReq id=0x1 <asyncmap 0x0> <auth eap> <magic 0x87f3474f> <pcomp> <accomp>]
rcvd [LCP ConfReq id=0x0 <asyncmap 0x0> <magic 0x6ecb1923> <pcomp> <accomp>]
sent [LCP ConfAck id=0x0 <asyncmap 0x0> <magic 0x6ecb1923> <pcomp> <accomp>]
sent [LCP ConfReq id=0x1 <asyncmap 0x0> <auth eap> <magic 0x87f3474f> <pcomp> <accomp>]
rcvd [LCP ConfAck id=0x1 <asyncmap 0x0> <auth eap> <magic 0x87f3474f> <pcomp> <accomp>]
sent [EAP Request id=0x67 Identity <Message "Name">]
rcvd [EAP Response id=0x67 Identity <Name "mike">]
EAP: unauthenticated peer name "mike"
sent [EAP Request id=0x68 TLS --S]
rcvd [EAP Response id=0x68 TLS L-- ...]
 <- Handshake: Client Hello
 -> Handshake: Server Hello
 -> Handshake: Certificate
 -> Handshake: Certificate Request
sent [EAP Request id=0x69 TLS LM- ...]
rcvd [EAP Response id=0x69 TLS Ack]
sent [EAP Request id=0x6a TLS --- ...]
rcvd [EAP Response id=0x6a TLS L-- ...]
 <- Handshake: Certificate
certificate verify depth: 1
certificate verify depth: 0
Certificate CN: mike , peer name mike
 <- Handshake: Client Key Exchange
 <- Handshake: Certificate Verify
 <- ChangeCipherSpec
 <- Handshake: Finished
 -> ChangeCipherSpec
 -> Handshake: Finished
sent [EAP Request id=0x6b TLS --- ...]
rcvd [EAP Response id=0x6b TLS Ack]
sent [EAP Success id=0x6c]
sent [CCP ConfReq id=0x1 <deflate 15> <deflate(old#) 15>]
sent [IPCP ConfReq id=0x1 <compress VJ 0f 01> <addr 192.168.10.2>]
rcvd [LCP ProtRej id=0x2 80 fd 01 01 00 0c 1a 04 78 00 18 04 78 00]
rcvd [IPCP ConfReq id=0x1 <compress VJ 0f 01> <addr 0.0.0.0> <ms-dns1 0.0.0.0> ...
sent [IPCP ConfRej id=0x1 <ms-dns1 0.0.0.0> <ms-wins 0.0.0.0> <ms-dns3 0.0.0.0> ...
rcvd [IPCP ConfAck id=0x1 <compress VJ 0f 01> <addr 192.168.10.2>]
rcvd [IPCP ConfReq id=0x3 <compress VJ 0f 01> <addr 0.0.0.0>]
sent [IPCP ConfNak id=0x3 <addr 192.168.10.3>]
rcvd [IPCP ConfReq id=0x4 <compress VJ 0f 01> <addr 192.168.10.3>]
sent [IPCP ConfAck id=0x4 <compress VJ 0f 01> <addr 192.168.10.3>]
local  IP address 192.168.10.2
remote IP address 192.168.10.3
Script /etc/ppp/ip-up started (pid 1741)
Script /etc/ppp/ip-up finished (pid 1741), status = 0x0

Analisi con ethereal del file conn.rec :
$ tethereal -r conn.rec
  1   0.00  DTE -> DCE   PPP LCP PPP LCP Configuration Request
  2   0.10  DCE -> DTE   PPP LCP PPP LCP Configuration Request
  3   0.10  DTE -> DCE   PPP LCP PPP LCP Configuration Ack
  4   3.00  DTE -> DCE   PPP LCP PPP LCP Configuration Request
  5   3.00  DCE -> DTE   PPP LCP PPP LCP Configuration Ack
  6   3.00  DTE -> DCE   EAP Request, Identity [RFC2284]
  7   3.10  DCE -> DTE   EAP Response, Identity [RFC2284]
  8   3.10  DTE -> DCE   EAP Request, EAP-TLS [RFC2716] [Aboba]
  9   3.10  DCE -> DTE   TLS Client Hello
 10   3.30  DTE -> DCE   EAP Request, EAP-TLS [RFC2716] [Aboba]
 11   3.30  DCE -> DTE   EAP Response, EAP-TLS [RFC2716] [Aboba]
 12   3.30  DTE -> DCE   TLS Server Hello, Certificate, Certificate Request, 
                          Server Hello Done
 13   3.50  DCE -> DTE   TLS Certificate, Client Key Exchange, Certificate Verify, 
                          Change Cipher Spec, Encrypted Handshake Message
 14   3.50  DTE -> DCE   TLS Change Cipher Spec, Encrypted Handshake Message
 15   3.50  DCE -> DTE   EAP Response, EAP-TLS [RFC2716] [Aboba]
 16   3.50  DTE -> DCE   EAP Success
 17   3.60  DTE -> DCE   PPP CCP PPP CCP Configuration Request
 18   3.60  DTE -> DCE   PPP IPCP PPP IPCP Configuration Request
 19   3.60  DCE -> DTE   PPP IPCP PPP IPCP Configuration Request
 20   3.60  DCE -> DTE   PPP LCP PPP LCP Protocol Reject
 21   3.60  DTE -> DCE   PPP IPCP PPP IPCP Configuration Reject
 22   3.60  DCE -> DTE   PPP IPCP PPP IPCP Configuration Ack
 23   3.60  DCE -> DTE   PPP IPCP PPP IPCP Configuration Request
 24   3.60  DTE -> DCE   PPP IPCP PPP IPCP Configuration Nak
 25   3.60  DCE -> DTE   PPP IPCP PPP IPCP Configuration Request
 26   3.60  DTE -> DCE   PPP IPCP PPP IPCP Configuration Ack
Analisi dettagliata dei pacchetti EAP e EAP-TLS
$ tethereal -V -r conn.rec

[...]

Frame 6 (13 bytes on wire, 13 bytes captured)
    Arrival Time: Mar 22, 2005 13:49:56.300000000
    Time delta from previous packet: 0.000000000 seconds
    Time relative to first packet: 3.000000000 seconds
    Frame Number: 6
    Packet Length: 13 bytes
    Capture Length: 13 bytes
    Point-to-Point Direction: Sent (0)
Point-to-Point Protocol
    Protocol: Extensible Authentication Protocol (0xc227)
Extensible Authentication Protocol
    Code: Request (1)
    Id: 103
    Length: 9
    Type: Identity [RFC2284] (1)
    Identity (4 bytes): Name

Frame 7 (13 bytes on wire, 13 bytes captured)
    Arrival Time: Mar 22, 2005 13:49:56.400000000
    Time delta from previous packet: 0.100000000 seconds
    Time relative to first packet: 3.100000000 seconds
    Frame Number: 7
    Packet Length: 13 bytes
    Capture Length: 13 bytes
    Point-to-Point Direction: Received (1)
Point-to-Point Protocol
    Protocol: Extensible Authentication Protocol (0xc227)
Extensible Authentication Protocol
    Code: Response (2)
    Id: 103
    Length: 9
    Type: Identity [RFC2284] (1)
    Identity (4 bytes): mike

Frame 8 (10 bytes on wire, 10 bytes captured)
    Arrival Time: Mar 22, 2005 13:49:56.400000000
    Time delta from previous packet: 0.000000000 seconds
    Time relative to first packet: 3.100000000 seconds
    Frame Number: 8
    Packet Length: 10 bytes
    Capture Length: 10 bytes
    Point-to-Point Direction: Sent (0)
Point-to-Point Protocol
    Protocol: Extensible Authentication Protocol (0xc227)
Extensible Authentication Protocol
    Code: Request (1)
    Id: 104
    Length: 6
    Type: EAP-TLS [RFC2716] [Aboba] (13)
    Flags(0x20): Start 

Frame 9 (84 bytes on wire, 84 bytes captured)
    Arrival Time: Mar 22, 2005 13:49:56.400000000
    Time delta from previous packet: 0.000000000 seconds
    Time relative to first packet: 3.100000000 seconds
    Frame Number: 9
    Packet Length: 84 bytes
    Capture Length: 84 bytes
    Point-to-Point Direction: Received (1)
Point-to-Point Protocol
    Protocol: Extensible Authentication Protocol (0xc227)
Extensible Authentication Protocol
    Code: Response (2)
    Id: 104
    Length: 80
    Type: EAP-TLS [RFC2716] [Aboba] (13)
    Flags(0x80): Length 
    Length: 70
    Secure Socket Layer
        SSL Record Layer: Client Hello
            Content Type: Handshake (22)
            Version: TLS 1.0 (0x0301)
            Length: 65
            Handshake Protocol: Client Hello
                Handshake Type: Client Hello (1)
                Length: 61
                Version: TLS 1.0 (0x0301)
                Random.gmt_unix_time: Mar 22, 2005 13:49:30.000000000
                Random.bytes
                Session ID Length: 0
                Cipher Suites Length: 22
                Cipher Suites (11 suites)
                    Cipher Suite: TLS_RSA_WITH_RC4_128_MD5 (0x0004)
                    Cipher Suite: TLS_RSA_WITH_RC4_128_SHA (0x0005)
                    Cipher Suite: TLS_RSA_WITH_3DES_EDE_CBC_SHA (0x000a)
                    Cipher Suite: TLS_RSA_WITH_DES_CBC_SHA (0x0009)
                    Cipher Suite: TLS_RSA_EXPORT1024_WITH_RC4_56_SHA (0x0064)
                    Cipher Suite: TLS_RSA_EXPORT1024_WITH_DES_CBC_SHA (0x0062)
                    Cipher Suite: TLS_RSA_EXPORT_WITH_RC4_40_MD5 (0x0003)
                    Cipher Suite: TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5 (0x0006)
                    Cipher Suite: TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA (0x0013)
                    Cipher Suite: TLS_DHE_DSS_WITH_DES_CBC_SHA (0x0012)
                    Cipher Suite: TLS_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA (0x0063)
                Compression Methods Length: 1
                Compression Methods (1 method)
                    Compression Method: null (0)

Frame 10 (1500 bytes on wire, 1500 bytes captured)
    Arrival Time: Mar 22, 2005 13:49:56.600000000
    Time delta from previous packet: 0.200000000 seconds
    Time relative to first packet: 3.300000000 seconds
    Frame Number: 10
    Packet Length: 1500 bytes
    Capture Length: 1500 bytes
    Point-to-Point Direction: Sent (0)
Point-to-Point Protocol
    Protocol: Extensible Authentication Protocol (0xc227)
Extensible Authentication Protocol
    Code: Request (1)
    Id: 105
    Length: 1496
    Type: EAP-TLS [RFC2716] [Aboba] (13)
    Flags(0xC0): Length More 
    Length: 1695

Frame 11 (10 bytes on wire, 10 bytes captured)
    Arrival Time: Mar 22, 2005 13:49:56.600000000
    Time delta from previous packet: 0.000000000 seconds
    Time relative to first packet: 3.300000000 seconds
    Frame Number: 11
    Packet Length: 10 bytes
    Capture Length: 10 bytes
    Point-to-Point Direction: Received (1)
Point-to-Point Protocol
    Protocol: Extensible Authentication Protocol (0xc227)
Extensible Authentication Protocol
    Code: Response (2)
    Id: 105
    Length: 6
    Type: EAP-TLS [RFC2716] [Aboba] (13)
    Flags(0x0): 

Frame 12 (219 bytes on wire, 219 bytes captured)
    Arrival Time: Mar 22, 2005 13:49:56.600000000
    Time delta from previous packet: 0.000000000 seconds
    Time relative to first packet: 3.300000000 seconds
    Frame Number: 12
    Packet Length: 219 bytes
    Capture Length: 219 bytes
    Point-to-Point Direction: Sent (0)
Point-to-Point Protocol
    Protocol: Extensible Authentication Protocol (0xc227)
Extensible Authentication Protocol
    Code: Request (1)
    Id: 106
    Length: 215
    Type: EAP-TLS [RFC2716] [Aboba] (13)
    Flags(0x0): 
    EAP-TLS Fragments
        Frame:10 payload:0-1485
        Frame:12 payload:1486-1694
    Secure Socket Layer
        TLS Record Layer: Server Hello
            Content Type: Handshake (22)
            Version: TLS 1.0 (0x0301)
            Length: 74
            Handshake Protocol: Server Hello
                Handshake Type: Server Hello (2)
                Length: 70
                Version: TLS 1.0 (0x0301)
                Random.gmt_unix_time: Mar 22, 2005 13:49:56.000000000
                Random.bytes
                Session ID Length: 32
                Session ID (32 bytes)
                Cipher Suite: TLS_RSA_WITH_RC4_128_MD5 (0x0004)
                Compression Method: null (0)
        TLS Record Layer: Certificate
            Content Type: Handshake (22)
            Version: TLS 1.0 (0x0301)
            Length: 1503
            Handshake Protocol: Certificate
                Handshake Type: Certificate (11)
                Length: 1499
                Certificates Length: 1496
                Certificates (1496 bytes)
                    Certificate Length: 763
                    Certificate (763 bytes)
                    Certificate Length: 727
                    Certificate (727 bytes)
        TLS Record Layer: Multiple Handshake Messages
            Content Type: Handshake (22)
            Version: TLS 1.0 (0x0301)
            Length: 103
            Handshake Protocol: Certificate Request
                Handshake Type: Certificate Request (13)
                Length: 95
                Certificate types count: 2
                Certificate types (2 types)
                    Certificate type: RSA Sign (1)
                    Certificate type: DSS Sign (2)
                Distinguished Names Length: 90
                Distinguished Names (90 bytes)
                    Distinguished Name Length: 88
                    Distinguished Name (88 bytes)
            Handshake Protocol: Server Hello Done
                Handshake Type: Server Hello Done (14)
                Length: 0

Frame 13 (1091 bytes on wire, 1091 bytes captured)
    Arrival Time: Mar 22, 2005 13:49:56.800000000
    Time delta from previous packet: 0.200000000 seconds
    Time relative to first packet: 3.500000000 seconds
    Frame Number: 13
    Packet Length: 1091 bytes
    Capture Length: 1091 bytes
    Point-to-Point Direction: Received (1)
Point-to-Point Protocol
    Protocol: Extensible Authentication Protocol (0xc227)
Extensible Authentication Protocol
    Code: Response (2)
    Id: 106
    Length: 1087
    Type: EAP-TLS [RFC2716] [Aboba] (13)
    Flags(0x80): Length 
    Length: 1077
    Secure Socket Layer
        TLS Record Layer: Multiple Handshake Messages
            Content Type: Handshake (22)
            Version: TLS 1.0 (0x0301)
            Length: 1029
            Handshake Protocol: Certificate
                Handshake Type: Certificate (11)
                Length: 757
                Certificates Length: 754
                Certificates (754 bytes)
                    Certificate Length: 751
                    Certificate (751 bytes)
            Handshake Protocol: Client Key Exchange
                Handshake Type: Client Key Exchange (16)
                Length: 130
            Handshake Protocol: Certificate Verify
                Handshake Type: Certificate Verify (15)
                Length: 130
        TLS Record Layer: Change Cipher Spec
            Content Type: Change Cipher Spec (20)
            Version: TLS 1.0 (0x0301)
            Length: 1
            Change Cipher Spec Message
        TLS Record Layer: Encrypted Handshake Message
            Content Type: Handshake (22)
            Version: TLS 1.0 (0x0301)
            Length: 32
            Handshake Protocol: Encrypted Handshake Message

Frame 14 (53 bytes on wire, 53 bytes captured)
    Arrival Time: Mar 22, 2005 13:49:56.800000000
    Time delta from previous packet: 0.000000000 seconds
    Time relative to first packet: 3.500000000 seconds
    Frame Number: 14
    Packet Length: 53 bytes
    Capture Length: 53 bytes
    Point-to-Point Direction: Sent (0)
Point-to-Point Protocol
    Protocol: Extensible Authentication Protocol (0xc227)
Extensible Authentication Protocol
    Code: Request (1)
    Id: 107
    Length: 49
    Type: EAP-TLS [RFC2716] [Aboba] (13)
    Flags(0x0): 
    Secure Socket Layer
        TLS Record Layer: Change Cipher Spec
            Content Type: Change Cipher Spec (20)
            Version: TLS 1.0 (0x0301)
            Length: 1
            Change Cipher Spec Message
        TLS Record Layer: Encrypted Handshake Message
            Content Type: Handshake (22)
            Version: TLS 1.0 (0x0301)
            Length: 32
            Handshake Protocol: Encrypted Handshake Message

Frame 15 (10 bytes on wire, 10 bytes captured)
    Arrival Time: Mar 22, 2005 13:49:56.800000000
    Time delta from previous packet: 0.000000000 seconds
    Time relative to first packet: 3.500000000 seconds
    Frame Number: 15
    Packet Length: 10 bytes
    Capture Length: 10 bytes
    Point-to-Point Direction: Received (1)
Point-to-Point Protocol
    Protocol: Extensible Authentication Protocol (0xc227)
Extensible Authentication Protocol
    Code: Response (2)
    Id: 107
    Length: 6
    Type: EAP-TLS [RFC2716] [Aboba] (13)
    Flags(0x0): 

Frame 16 (8 bytes on wire, 8 bytes captured)
    Arrival Time: Mar 22, 2005 13:49:56.800000000
    Time delta from previous packet: 0.000000000 seconds
    Time relative to first packet: 3.500000000 seconds
    Frame Number: 16
    Packet Length: 8 bytes
    Capture Length: 8 bytes
    Point-to-Point Direction: Sent (0)
Point-to-Point Protocol
    Protocol: Extensible Authentication Protocol (0xc227)
Extensible Authentication Protocol
    Code: Success (3)
    Id: 108
    Length: 4

[...]

Riferimenti

 

Beniamino Galvani, bengal@interfree.it