Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tls:create-certificates [2010/09/09 13:29] – 83.136.33.3 | tls:create-certificates [2010/09/30 16:53] (current) – 87.93.52.7 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Create Certificates to be used with Kamailio ====== | ||
+ | Creating suitable certificates for Kamailio is just as simple as configuring Apache with SSL/TLS. If you do not have certificates you can use the " | ||
+ | |||
+ | ===== Creating Certificates with OpenSSL ===== | ||
+ | |||
+ | Following example was done on a Debian Lenny installation. On other Linux distributions you may have to adopt the openssl.cnf file (e.g. / | ||
+ | |||
+ | * Change the default policy to be more flexible, edit / | ||
+ | |||
+ | ... | ||
+ | # A few difference way of specifying how similar the request should look | ||
+ | # For type CA, the listed attributes must be the same, and the optional | ||
+ | # and supplied fields are just that :-) | ||
+ | policy | ||
+ | ... | ||
+ | |||
+ | * Make a directory to store your certificates (of course you should secure this directory to prevent unprivileged access): | ||
+ | |||
+ | mkdir /etc/certs | ||
+ | chmod 0700 /etc/certs | ||
+ | cd /etc/certs | ||
+ | |||
+ | * Create a self-signed CA (cartificate authority) certificate (valid for 10 years): | ||
+ | |||
+ | mkdir demoCA | ||
+ | cd demoCA | ||
+ | mkdir newcerts | ||
+ | echo ' | ||
+ | touch index.txt | ||
+ | openssl req -new -x509 -extensions v3_ca -keyout key.pem -out cert.pem -days 3650 | ||
+ | # Optional, verify the content of the new CA certificate: | ||
+ | openssl x509 -in cert.pem -noout -text | ||
+ | openssl x509 -in cert.pem -noout -dates | ||
+ | openssl x509 -in cert.pem -noout -purpose | ||
+ | cd .. | ||
+ | |||
+ | * Make a certificate for your SIP proxy sip.mydomain.com (create keys and a certificate signing request (CSR), then sign the CSR with the CA's certificate) | ||
+ | |||
+ | mkdir sip.mydomain.com | ||
+ | cd sip.mydomain.com/ | ||
+ | openssl req -new -nodes -keyout key.pem -out req.pem | ||
+ | cd .. | ||
+ | openssl ca -days 730 -out sip.mydomain.com/ | ||
+ | |||
+ | * Make a certificate for another SIP proxy anotherdomain.com (create keys and a certificate signing request (CSR), then sign the CSR with the CA's certificate) | ||
+ | |||
+ | mkdir anotherdomain.com | ||
+ | cd anotherdomain.com/ | ||
+ | openssl req -new -nodes -keyout key.pem -out req.pem | ||
+ | cd .. | ||
+ | openssl ca -days 730 -out anotherdomain.com/ | ||
+ | |||
+ | * Optional, verify the content of the new certificates: | ||
+ | |||
+ | openssl x509 -in anotherdomain.com/ | ||
+ | openssl x509 -in sip.mydomain.com/ | ||
+ | ==== Using the Certificates with TLS ==== | ||
+ | |||
+ | * Now you can use these certificates with Kamailio, e.g: (following snippet is for Kamailio 3.0 and 3.1)< | ||
+ | enable_tls=1 | ||
+ | tcp_async=no | ||
+ | tcp_connection_lifetime=3610 | ||
+ | listen=udp:< | ||
+ | listen=tcp:< | ||
+ | | ||
+ | modparam(" | ||
+ | modparam(" | ||
+ | modparam(" | ||
+ | </ | ||
+ | * If you want to have different certificates in function of the role (server or client), or who are you talking with, you need to use a separate tls config file, see http:// | ||
+ | |||
+ | ==== Using TLS and the Certificates with SIP Phones ==== | ||
+ | |||
+ | * Further, you SIP client needs to be provisioned with to trust your self-signed CA. Depending on your SIP client there are various options how to configure, e.g.: | ||
+ | * eyebeam: copy the CA certificate (/ | ||
+ | * QjSimple: copy the CA certificate (/ | ||
+ | * Snom Phones: by default Snom accepts untrusted certificates, | ||
+ | |||
+ | ==== Testing ==== | ||
+ | |||
+ | * You can test with the openssl tools, e.g. connecting to the server without certificate validation: | ||
+ | |||
+ | # openssl s_client -connect localhost: | ||
+ | CONNECTED(00000003) | ||
+ | depth=1 / | ||
+ | verify error: | ||
+ | verify return:0 | ||
+ | |||
+ | * Connecting to the server without certificate validation: | ||
+ | |||
+ | # openssl s_client -connect localhost: | ||
+ | CONNECTED(00000003) | ||
+ | depth=1 / | ||
+ | verify return:1 | ||
+ | depth=0 / | ||
+ | verify return:1 | ||
+ | |||
+ | ==== Example ==== | ||
+ | |||
+ | < | ||
+ | debian:/ | ||
+ | debian:/ | ||
+ | debian:/ | ||
+ | debian:/ | ||
+ | debian:/ | ||
+ | debian:/ | ||
+ | debian:/ | ||
+ | debian:/ | ||
+ | debian:/ | ||
+ | Generating a 1024 bit RSA private key | ||
+ | ...................................................++++++ | ||
+ | .........................++++++ | ||
+ | writing new private key to ' | ||
+ | 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 ' | ||
+ | ----- | ||
+ | Country Name (2 letter code) [AU]:AT | ||
+ | State or Province Name (full name) [Some-State]: | ||
+ | Locality Name (eg, city) []:Vienna | ||
+ | Organization Name (eg, company) [Internet Widgits Pty Ltd]:My private CA | ||
+ | Organizational Unit Name (eg, section) []: | ||
+ | Common Name (eg, YOUR name) []:My private CA | ||
+ | Email Address []: | ||
+ | debian:/ | ||
+ | |||
+ | |||
+ | debian:/ | ||
+ | debian:/ | ||
+ | debian:/ | ||
+ | Generating a 1024 bit RSA private key | ||
+ | .....................................++++++ | ||
+ | ..................++++++ | ||
+ | writing new private key to ' | ||
+ | ----- | ||
+ | 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 ' | ||
+ | ----- | ||
+ | Country Name (2 letter code) [AU]:AT | ||
+ | State or Province Name (full name) [Some-State]: | ||
+ | Locality Name (eg, city) []:Berlin | ||
+ | Organization Name (eg, company) [Internet Widgits Pty Ltd]: | ||
+ | Organizational Unit Name (eg, section) []: | ||
+ | Common Name (eg, YOUR name) []: | ||
+ | Email Address []: | ||
+ | |||
+ | Please enter the following ' | ||
+ | to be sent with your certificate request | ||
+ | A challenge password []: | ||
+ | An optional company name []: | ||
+ | debian:/ | ||
+ | debian:/ | ||
+ | Using configuration from / | ||
+ | Enter pass phrase for demoCA/ | ||
+ | Check that the request matches the signature | ||
+ | Signature ok | ||
+ | Certificate Details: | ||
+ | Serial Number: 2 (0x2) | ||
+ | Validity | ||
+ | Not Before: Sep 9 13:42:27 2010 GMT | ||
+ | Not After : Sep 8 13:42:27 2012 GMT | ||
+ | Subject: | ||
+ | countryName | ||
+ | localityName | ||
+ | organizationName | ||
+ | commonName | ||
+ | X509v3 extensions: | ||
+ | X509v3 Basic Constraints: | ||
+ | CA:FALSE | ||
+ | Netscape Comment: | ||
+ | OpenSSL Generated Certificate | ||
+ | X509v3 Subject Key Identifier: | ||
+ | 65: | ||
+ | X509v3 Authority Key Identifier: | ||
+ | keyid: | ||
+ | |||
+ | Certificate is to be certified until Sep 8 13:42:27 2012 GMT (730 days) | ||
+ | Sign the certificate? | ||
+ | |||
+ | |||
+ | 1 out of 1 certificate requests certified, commit? [y/n]y | ||
+ | Write out database with 1 new entries | ||
+ | Data Base Updated | ||
+ | debian:/ | ||
+ | </ |