MIME-Version: 1.0 From: Lucas Mocellin Date: Wed, 17 Jun 2009 12:28:20 -0300 Message-ID: Content-Type: multipart/alternative; boundary=0016e6de016c1ede39046c8cf23a Subject: [Openvpn-devel] maybe a bug in pkitool script List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: openvpn-devel --0016e6de016c1ede39046c8cf23a Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hi, I would like to inform/contribute with some situation I got now. At first, I would like to change the "CA" directory from the "clients/server" certificate because I want to use ./clean-all to refresh the client certificates, and let the CA original, so I let vars with the "clients" keys/certs and in the openssl.cnf I changed the CA location: [ CA_default ] # CHANGES TO AVOID ./clean-all TO DELETE CA dirCA = /etc/openvpn/2.0/ca dir = $ENV::KEY_DIR # Where everything is kept certs = $dir # Where the issued certs are kept crl_dir = $dirCA # Where the issued crl are kept database = $dirCA/index.txt # database index file. new_certs_dir = $dir # default place for new certs. certificate = $dirCA/ca.crt # The CA certificate serial = $dirCA/serial # The current serial number crl = $dirCA/crl.pem # The current CRL private_key = $dirCA/ca.key # The private key RANDFILE = $dirCA/.rand # private random number file In the "pkitool" script which comes with the openvpn, I noticed that when it builds a new client/server cert he uses the openssl "-config openssl.cnf" diretive(1), but to check if the CA exists, it uses the $KEY_DIR in vars(2). (1) # Build cert/key ( [ $DO_REQ -eq 0 ] || $OPENSSL req $BATCH -days $KEY_EXPIRE $NODES_REQ -new -newkey rsa:$KEY_SIZE \ -keyout "$KEY_CN.key" -out "$KEY_CN.csr" $REQ_EXT -config "$KEY_CONFIG" $PKCS11_ARGS ) && \ ( [ $DO_CA -eq 0 ] || $OPENSSL ca $BATCH -days $KEY_EXPIRE -out "$KEY_CN.crt" \ -in "$KEY_CN.csr" $CA_EXT -md sha1 -config "$KEY_CONFIG" ) && \ ( [ $DO_P12 -eq 0 ] || $OPENSSL pkcs12 -export -inkey "$KEY_CN.key" \ -in "$KEY_CN.crt" -certfile "$CA.crt" -out "$KEY_CN.p12" $NODES_P12 ) && \ ( [ $DO_CA -eq 0 -o $DO_P11 -eq 1 ] || chmod 0600 "$KEY_CN.key" ) && \ ( [ $DO_P12 -eq 0 ] || chmod 0600 "$KEY_CN.p12" ) (2) # Make sure CA key/cert is available if [ $DO_CA -eq 1 ] || [ $DO_P12 -eq 1 ]; then if [ ! -r "$CA.crt" ] || [ ! -r "$CA.key" ]; then echo "$PROGNAME: Need a readable $CA.crt and $CA.key in $KEY_DIR" echo "Try $PROGNAME --initca to build a root certificate/key." exit 1 fi fi Is that considered a bug? Thanks in advance, Lucas Mocellin. --0016e6de016c1ede39046c8cf23a Content-Type: text/html; charset="ISO-8859-1" Content-Transfer-Encoding: quoted-printable Hi,

I would like to inform/contribute with some situation I got now.=

At first, I would like to change the "CA" directory from = the "clients/server" certificate because I want to use ./clean-al= l to refresh the client certificates, and let the CA original, so I let var= s with the "clients" keys/certs and in the openssl.cnf I changed = the CA location:

[ CA_default ]

# CHANGES TO AVOID ./clean-all TO DELETE CA
di= rCA=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =3D /etc/openvpn/2.0/ca
dir=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0 =3D $ENV::KEY_DIR=A0=A0=A0=A0=A0=A0=A0=A0 # Whe= re everything is kept
certs=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =3D $dir=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 # Where the issued certs are = kept
crl_dir=A0=A0=A0=A0=A0=A0=A0=A0 =3D $dirCA=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 # Where the issued crl are kept
dat= abase=A0=A0=A0=A0=A0=A0=A0 =3D $dirCA/index.txt=A0=A0=A0=A0=A0 # database i= ndex file.
new_certs_dir=A0=A0 =3D $dir=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0 # default place for new certs.

certificate=A0=A0=A0=A0 =3D $dirCA/ca.crt=A0=A0=A0=A0=A0=A0=A0=A0 # The= CA certificate
serial=A0=A0=A0=A0=A0=A0=A0=A0=A0 =3D $dirCA/serial=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 # The current serial numbercrl=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =3D $dirCA/crl.pem=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 # The current CRL
private_key=A0=A0=A0=A0= =3D $dirCA/ca.key=A0=A0=A0=A0=A0=A0=A0=A0 # The private key
RANDFILE=A0=A0=A0=A0=A0=A0=A0 =3D $dirCA/.rand=A0=A0=A0=A0=A0=A0=A0=A0=A0 #= private random number file

In the "pkitool" script which = comes with the openvpn, I noticed that when it builds a new client/server c= ert he uses the openssl "-config openssl.cnf" diretive(1), but to= check if the CA exists, it uses the $KEY_DIR in vars(2).

(1)=A0=A0=A0=A0=A0=A0=A0=A0 # Build cert/key
=A0=A0=A0=A0=A0=A0=A0 (= [ $DO_REQ -eq 0 ] || $OPENSSL req $BATCH -days $KEY_EXPIRE $NODES_REQ -new= -newkey rsa:$KEY_SIZE \
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 -= keyout "$KEY_CN.key" -out "$KEY_CN.csr" $REQ_EXT -confi= g "$KEY_CONFIG" $PKCS11_ARGS ) && \
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 ( [ $DO_CA -eq 0 ]=A0 || $OPENSSL ca $BAT= CH -days $KEY_EXPIRE -out "$KEY_CN.crt" \
=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0 -in "$KEY_CN.csr" $CA_EXT -md sha1 -c= onfig "$KEY_CONFIG" ) && \
=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0 ( [ $DO_P12 -eq 0 ] || $OPENSSL pkcs12 -export -inkey "$KEY_CN.= key" \
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 -in "$KEY_CN.crt" -= certfile "$CA.crt" -out "$KEY_CN.p12" $NODES_P12 ) &= ;& \
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 ( [ $DO_CA -eq 0 -o $DO_P11 -= eq 1 ]=A0 || chmod 0600 "$KEY_CN.key" ) && \
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 ( [ $DO_P12 -eq 0 ] || chmod 0600 "$= KEY_CN.p12" )


(2)=A0=A0=A0=A0=A0=A0=A0=A0 # Make sure CA ke= y/cert is available
=A0=A0=A0=A0=A0=A0 if [ $DO_CA -eq 1 ] || [ $DO_P12 = -eq 1 ]; then
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 if [ ! -r "$CA.crt&quo= t; ] || [ ! -r "$CA.key" ]; then
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 echo "$PROGNAME: Need a rea= dable $CA.crt and $CA.key in $KEY_DIR"
=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0 echo "Try $PROGNAME --initca to build a root certifica= te/key."
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 exit 1
=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0 fi
=A0=A0=A0=A0=A0=A0 fi


Is that considered a bug?

Thanks in= advance,

Lucas Mocellin.
--0016e6de016c1ede39046c8cf23a--