updating OpenSSL locks OpenVPN, why? [SOLVED]

How to customize and extend your OpenVPN installation.

Moderators: TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech

Post Reply
cmatte
OpenVpn Newbie
Posts: 15
Joined: Wed Feb 02, 2011 7:03 pm

updating OpenSSL locks OpenVPN, why? [SOLVED]

Post by cmatte » Fri Feb 11, 2011 11:14 am

Hi,
I want to update OpenSSL and sign my certificates with the newest one with the latest vulnerability fixes but I didn't manage it to work. I am using OpenVPN 2.2-beta5 and OpenSSL 0.9.8q [2 Dec 2010].
I am on Windows 7 x64 and I had some headaches to make it "like" the openvpn openssl.cnf but at the end I managed to create every certificate correctly adapting some easy-rsa script to the new commands (or so it seems).
Now the server/client no more do authenticate with this error on the client:
Fri Feb 11 12:02:30 2011 TLS_ERROR: BIO read tls_read_plaintext error: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Fri Feb 11 12:02:30 2011 TLS Error: TLS object -> incoming plaintext read error
Fri Feb 11 12:02:30 2011 TLS Error: TLS handshake failed
Fri Feb 11 12:02:30 2011 SIGUSR1[soft,tls-error] received, process restarting
and this on the server:
Fri Feb 11 12:10:39 2011 ip:port TLS Error: TLS key negotiation failed to occur within 60 seconds (check your network connectivity)
Fri Feb 11 12:10:39 2011 ip:port TLS Error: TLS handshake failed
Fri Feb 11 12:10:39 2011 ip:port SIGUSR1[soft,tls-error] received, client-instance restarting
How can I manage it to work?
I am absolutely sure the same exact configuration worked with certs generated with the included vulnerable OpenSSL.
Am I obliged to use the it to make it work? What to do if I want to use the latest?
Thanks!
Last edited by cmatte on Fri Feb 11, 2011 2:42 pm, edited 1 time in total.

User avatar
janjust
Forum Team
Posts: 2703
Joined: Fri Aug 20, 2010 2:57 pm
Location: Amsterdam
Contact:

Re: updating OpenSSL locks OpenVPN, why?

Post by janjust » Fri Feb 11, 2011 11:23 am

it sounds like you generated new certificates on one side , but not the other. Why did you want to generate new certs anyway?
the errors you're seeing are related to the fact that the client no longer trusts the server certificate, and aborts the connection.

Try copying over the old client cert (and ca.crt) from the server, if you still have it , and reconnect.

HTH,

JJK

cmatte
OpenVpn Newbie
Posts: 15
Joined: Wed Feb 02, 2011 7:03 pm

Re: updating OpenSSL locks OpenVPN, why?

Post by cmatte » Fri Feb 11, 2011 11:53 am

I've double checked the ca.crt and it's the right, new, one. The CA file could be the only matter, given the error?
I've generated all the certs 3-4 times to try and isolate the error and I'm always getting this...
What about ta.key? Should it be as long as the dh? Or how much?

User avatar
janjust
Forum Team
Posts: 2703
Joined: Fri Aug 20, 2010 2:57 pm
Location: Amsterdam
Contact:

Re: updating OpenSSL locks OpenVPN, why?

Post by janjust » Fri Feb 11, 2011 12:25 pm

the ca.crt file on both client and server should be the same for your setup.

the client.crt file needs to be signed by this ca

the server.crt on the server also needs to be signed by this ca.crt

the ta.key file is generated by openvpn itself (using 'openvpn --genkey') ; it should be the same on both client and server

HTH,

JJK

cmatte
OpenVpn Newbie
Posts: 15
Joined: Wed Feb 02, 2011 7:03 pm

Re: updating OpenSSL locks OpenVPN, why?

Post by cmatte » Fri Feb 11, 2011 12:32 pm

Thanks, that was clear before too, I got a more verbose log from the client and I found the error! I'm using the remote-cert-tls server directive and it seems easy-rsa didn't sign the certificate with the wanted key usage extension:

Code: Select all

Fri Feb 11 13:27:20 2011 us=896000 TLS: Initial packet from ip:port, sid=0c00017d 0cee00c0
Fri Feb 11 13:27:56 2011 us=854000 VERIFY OK: depth=1, /C=CT/ST=ST/L=L/O=O/OU=OU/CN=CA/emailAddress=aa@aa.aa
Fri Feb 11 13:27:56 2011 us=854000 Certificate does not have key usage extension
Fri Feb 11 13:27:56 2011 us=854000 VERIFY KU ERROR
Fri Feb 11 13:27:56 2011 us=854000 TLS_ERROR: BIO read tls_read_plaintext error: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Fri Feb 11 13:27:56 2011 us=854000 TLS Error: TLS object -> incoming plaintext read error
Fri Feb 11 13:27:56 2011 us=854000 TLS Error: TLS handshake failed
Fri Feb 11 13:27:56 2011 us=854000 TCP/UDP: Closing socket
Fri Feb 11 13:27:56 2011 us=854000 SIGUSR1[soft,tls-error] received, process restarting
Since it's said everywhere the newer easy-rsa does this by itself and doesn't give any understandable (for me) directives on how to implement this, how should I do? I think this should be written in the openssl.cnf file, right?
I report the one my openvpn packet includes:

Code: Select all

#
# OpenSSL example configuration file.
# This is mostly being used for generation of certificate requests.
#

# This definition stops the following lines choking if HOME isn't
# defined.
HOME			= .
RANDFILE		= $ENV::HOME/.rnd

# Extra OBJECT IDENTIFIER info:
#oid_file		= $ENV::HOME/.oid
oid_section		= new_oids

# To use this configuration file with the "-extfile" option of the
# "openssl x509" utility, name here the section containing the
# X.509v3 extensions to use:
# extensions		= 
# (Alternatively, use a configuration file that has only
# X.509v3 extensions in its main [= default] section.)

[ new_oids ]

# We can add new OIDs in here for use by 'ca' and 'req'.
# Add a simple OID like this:
# testoid1=1.2.3.4
# Or use config file substitution like this:
# testoid2=${testoid1}.5.6

####################################################################
[ ca ]
default_ca	= CA_default		# The default ca section

####################################################################
[ CA_default ]

dir		= $ENV::KEY_DIR		# Where everything is kept
certs		= $dir			# Where the issued certs are kept
crl_dir		= $dir			# Where the issued crl are kept
database	= $dir/index.txt	# database index file.
new_certs_dir	= $dir			# default place for new certs.

certificate	= $dir/ca.crt	 	# The CA certificate
serial		= $dir/serial 		# The current serial number
crl		= $dir/crl.pem 		# The current CRL
private_key	= $dir/ca.key	 	# The private key
RANDFILE	= $dir/.rand		# private random number file

x509_extensions	= usr_cert		# The extentions to add to the cert

# Extensions to add to a CRL. Note: Netscape communicator chokes on V2 CRLs
# so this is commented out by default to leave a V1 CRL.
# crl_extensions	= crl_ext

default_days	= 3650			# how long to certify for
default_crl_days= 30			# how long before next CRL
default_md	= md5			# which md to use.
preserve	= no			# keep passed DN ordering

# 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		= policy_match

# For the CA policy
[ policy_match ]
countryName		= match
stateOrProvinceName	= match
organizationName	= match
organizationalUnitName	= optional
commonName		= supplied
emailAddress		= optional

# For the 'anything' policy
# At this point in time, you must list all acceptable 'object'
# types.
[ policy_anything ]
countryName		= optional
stateOrProvinceName	= optional
localityName		= optional
organizationName	= optional
organizationalUnitName	= optional
commonName		= supplied
emailAddress		= optional

####################################################################
[ req ]
default_bits		= $ENV::KEY_SIZE
default_keyfile 	= privkey.pem
distinguished_name	= req_distinguished_name
attributes		= req_attributes
x509_extensions	= v3_ca	# The extentions to add to the self signed cert

# Passwords for private keys if not present they will be prompted for
# input_password = secret
# output_password = secret

# This sets a mask for permitted string types. There are several options. 
# default: PrintableString, T61String, BMPString.
# pkix	 : PrintableString, BMPString.
# utf8only: only UTF8Strings.
# nombstr : PrintableString, T61String (no BMPStrings or UTF8Strings).
# MASK:XXXX a literal mask value.
# WARNING: current versions of Netscape crash on BMPStrings or UTF8Strings
# so use this option with caution!
string_mask = nombstr

# req_extensions = v3_req # The extensions to add to a certificate request

[ req_distinguished_name ]
countryName			= Country Name (2 letter code)
countryName_default		= $ENV::KEY_COUNTRY
countryName_min			= 2
countryName_max			= 2

stateOrProvinceName		= State or Province Name (full name)
stateOrProvinceName_default	= $ENV::KEY_PROVINCE

localityName			= Locality Name (eg, city)
localityName_default		= $ENV::KEY_CITY

0.organizationName		= Organization Name (eg, company)
0.organizationName_default	= $ENV::KEY_ORG

# we can do this but it is not needed normally :-)
#1.organizationName		= Second Organization Name (eg, company)
#1.organizationName_default	= World Wide Web Pty Ltd

organizationalUnitName		= Organizational Unit Name (eg, section)
#organizationalUnitName_default	=

commonName			= Common Name (eg, your name or your server\'s hostname)
commonName_max			= 64

emailAddress			= Email Address
emailAddress_default		= $ENV::KEY_EMAIL
emailAddress_max		= 40

# SET-ex3			= SET extension number 3

[ req_attributes ]
challengePassword		= A challenge password
challengePassword_min		= 4
challengePassword_max		= 20

unstructuredName		= An optional company name

[ usr_cert ]

# These extensions are added when 'ca' signs a request.

# This goes against PKIX guidelines but some CAs do it and some software
# requires this to avoid interpreting an end user certificate as a CA.

basicConstraints=CA:FALSE

# Here are some examples of the usage of nsCertType. If it is omitted
# the certificate can be used for anything *except* object signing.

# This is OK for an SSL server.
# nsCertType			= server

# For an object signing certificate this would be used.
# nsCertType = objsign

# For normal client use this is typical
# nsCertType = client, email

# and for everything including object signing:
# nsCertType = client, email, objsign

# This is typical in keyUsage for a client certificate.
# keyUsage = nonRepudiation, digitalSignature, keyEncipherment

# This will be displayed in Netscape's comment listbox.
nsComment			= "OpenSSL Generated Certificate"

# PKIX recommendations harmless if included in all certificates.
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid,issuer:always

# This stuff is for subjectAltName and issuerAltname.
# Import the email address.
# subjectAltName=email:copy

# Copy subject details
# issuerAltName=issuer:copy

#nsCaRevocationUrl		= http://www.domain.dom/ca-crl.pem
#nsBaseUrl
#nsRevocationUrl
#nsRenewalUrl
#nsCaPolicyUrl
#nsSslServerName

[ server ]

# JY ADDED -- Make a cert with nsCertType set to "server"
basicConstraints=CA:FALSE
nsCertType			= server
nsComment			= "OpenSSL Generated Server Certificate"
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid,issuer:always

[ v3_req ]

# Extensions to add to a certificate request

basicConstraints = CA:FALSE
keyUsage = nonRepudiation, digitalSignature, keyEncipherment

[ v3_ca ]


# Extensions for a typical CA


# PKIX recommendation.

subjectKeyIdentifier=hash

authorityKeyIdentifier=keyid:always,issuer:always

# This is what PKIX recommends but some broken software chokes on critical
# extensions.
#basicConstraints = critical,CA:true
# So we do this instead.
basicConstraints = CA:true

# Key usage: this is typical for a CA certificate. However since it will
# prevent it being used as an test self-signed certificate it is best
# left out by default.
# keyUsage = cRLSign, keyCertSign

# Some might want this also
# nsCertType = sslCA, emailCA

# Include email address in subject alt name: another PKIX recommendation
# subjectAltName=email:copy
# Copy issuer details
# issuerAltName=issuer:copy

# DER hex encoding of an extension: beware experts only!
# obj=DER:02:03
# Where 'obj' is a standard or added object
# You can even override a supported extension:
# basicConstraints= critical, DER:30:03:01:01:FF

[ crl_ext ]

# CRL extensions.
# Only issuerAltName and authorityKeyIdentifier make any sense in a CRL.

# issuerAltName=issuer:copy
authorityKeyIdentifier=keyid:always,issuer:always
What to change?
Thanks!

User avatar
janjust
Forum Team
Posts: 2703
Joined: Fri Aug 20, 2010 2:57 pm
Location: Amsterdam
Contact:

Re: updating OpenSSL locks OpenVPN, why?

Post by janjust » Fri Feb 11, 2011 12:40 pm

the [usr_cert] section should contain

Code: Select all

[ usr_cert ]
basicConstraints=CA:FALSE
nsComment           = "Easy-RSA Generated Certificate"
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid,issuer:always
extendedKeyUsage=clientAuth
keyUsage = digitalSignature
the [server] section should contain

Code: Select all

[ server ]

# JY ADDED -- Make a cert with nsCertType set to "server"
basicConstraints=CA:FALSE
nsCertType          = server
nsComment           = "Easy-RSA Generated Server Certificate"
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid,issuer:always
extendedKeyUsage=serverAuth
keyUsage = digitalSignature, keyEncipherment
then build the server key using

./build-key-server server-name

HTH,

JJK

cmatte
OpenVpn Newbie
Posts: 15
Joined: Wed Feb 02, 2011 7:03 pm

Re: updating OpenSSL locks OpenVPN, why?

Post by cmatte » Fri Feb 11, 2011 1:00 pm

Thanks!
Just redoing everything...will let you know soon!
p.s. for the developers: I remember I've downloaded the latest 'beta' version of openvpn before generating these new certs and have so many headaches, before I was using the same directive with no editing of the openssl.cnf file, so there should be the wrong file in the latest beta with no extended usage lines that was there in the stable version!!!

cmatte
OpenVpn Newbie
Posts: 15
Joined: Wed Feb 02, 2011 7:03 pm

Re: updating OpenSSL locks OpenVPN, why? [SOLVED]

Post by cmatte » Fri Feb 11, 2011 2:43 pm

Update: all perfect, it's working wonderfully now, thanks a lot JJ!!!

Post Reply