Creazione certificato self-signed, ovvero auto certificata, provata su Mandriva 2007. Necessario: Apache, OpenSSL, mod_ssl. File sul server: chiave (server.key) certificato da firmare (server.csr) certificato firmato dalla CA (server.crt) File CA self-signed: chiave (CA.key) certificato self-signed (CA.crt) -Creazione chiave primaria: # su (bisogna essere root) -creo una chiave RSA cifrata des3 a 1024 bit per la mia CA, mi verra' richiesta la passphrase, utilizzo la solita. # openssl genrsa -des3 -out CA.key 1024, mi verra' richiesta la passphrase, utilizzo la solita -creo un certificato, autocertificato, di formato x509 self-signed per la CA della durata di 5 anni, mi verra' richiesta la passphrase, utilizzo la solita. # openssl req -new -x509 -days 1825 -key CA.key -out CA.crt Enter pass phrase for CA.key:xxxxxxxxx -mi verranno richiesti anche i seguenti dati per configurare i certificati personalizzati: 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) [GB]:IT State or Province Name (full name) [Berkshire]:Roma Locality Name (eg, city) [Newbury]:RM Organization Name (eg, company) [My Company Ltd]:ArenaHome Organizational Unit Name (eg, section) []: Common Name (eg, your name or your server's hostname) []:arenahome.dyndns.org Email Address []:a124142@inwind.it -Creazione struttura, necessaria per OpenSSL: modifico, dopo aver salvato l'originale, /etc/pki/tls/openssl.cnf, sostituendo /etc/pki/tls con /home/a124142/myCA # pwd /home/a124142 # mkdir -p myCA/{private,newcerts} # cp CA.crt myCA/cacert.pem # cp CA.key myCA/private/cakey.pem # echo 01 > myCA/serial # touch myCA/index.txt -Generiamo la chiave: # openssl genrsa -des3 -out uno.key 1024 (richiede passphrase) -Generiamo il certificato da firmare: # openssl req -new -key uno.key -out uno.csr Country Name (2 letter code) [GB]:IT State or Province Name (full name) [Berkshire]:Roma Locality Name (eg, city) [Newbury]:RM Organization Name (eg, company) [My Company Ltd]:ArenaHome Organizational Unit Name (eg, section) []: Common Name (eg, your name or your server's hostname) []:arenahome.dyndns.org Email Address []:a124142@inwind.it -Certifichiamo tramite la nostra CA il certificato creato precedentemente: # openssl ca -in uno.csr -out uno.crt Cosi' ho tutto il necessario per realizzare il primo Virtual-Host: cd /etc/httpd/conf mkdir ssl.crt mkdir ssl.key cd /home/a124142/ cp CA.crt /etc/httpd/conf/ssl.crt/CA.crt chmod 600 /etc/httpd/conf/ssl.crt/CA.crt cp uno.crt /etc/httpd/conf/ssl.crt/uno.crt chmod 600 /etc/httpd/conf/ssl.crt/uno.crt cp uno.key /etc/httpd/conf/ssl.key/uno.key chmod 600 /etc/httpd/conf/ssl.key/uno.key -creazione dell' entrata in apache, mediante l'aggiunta in httpd.conf oppure nell'include, /etc/httpd/conf/vhosts.d/00_default_vhosts.conf -restart di apache # /etc/rc.d/init.d/httpd restart Prova con il browser in locale: https://localhost -Per evitare che venga richiesta la passphrase ogni volta: # cp uno.key uno.key.encrypted # openssl rsa -in uno.key.encrypted -out uno.key # cp uno.key /etc/httpd/conf/ssl.key/uno. # chmod 600 /etc/httpd/conf/ssl.key/uno.key# /etc/rc.d/init.d/httpd restart -restart di apache # /etc/rc.d/init.d/httpd restart Prova con il browser in locale: https://localhost -Attenzione in caso di aggiornamento di OpenSSL, ricordarsi di modificare /etc/pki/tls/openssl.cnf. -Per evitare di inserire ogni volta i dati richiesti e' anche possibile inserirli come default sempre in openssl.cnf.