Generate certificates & keys for clients

Scripts to manage certificates or generate config files

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

Post Reply
arturk
OpenVpn Newbie
Posts: 7
Joined: Tue Feb 10, 2015 1:33 pm
Location: Poland

Generate certificates & keys for clients

Post by arturk » Tue Feb 10, 2015 1:55 pm

Hi there,
I followed instructions at http://openvpn.net/index.php/open-sourc ... o.html#pki
and successful generated all needed certificates and keys. After few days I realized that I need two more client certificates. I tried to build them using 'build-key clientX' but I get an error. It's probably associated with lost variable values. How to manage it and not to rewrite generated certs and keys?

User avatar
maikcat
Forum Team
Posts: 4200
Joined: Wed Jan 12, 2011 9:23 am
Location: Athens,Greece
Contact:

Re: Generate certificates & keys for clients

Post by maikcat » Tue Feb 10, 2015 1:58 pm

if you have ca.key index.txt etc you must run first vars script THEN create your client certs.

Michael.

arturk
OpenVpn Newbie
Posts: 7
Joined: Tue Feb 10, 2015 1:33 pm
Location: Poland

Re: Generate certificates & keys for clients

Post by arturk » Tue Feb 10, 2015 2:02 pm

maikcat wrote:if you have ca.key index.txt etc you must run first vars script THEN create your client certs.

Michael.
I've done it this way. Still doesn't work :-/

User avatar
maikcat
Forum Team
Posts: 4200
Joined: Wed Jan 12, 2011 9:23 am
Location: Athens,Greece
Contact:

Re: Generate certificates & keys for clients

Post by maikcat » Tue Feb 10, 2015 5:30 pm

please post the exact commands used and the output you get.

Michael.

arturk
OpenVpn Newbie
Posts: 7
Joined: Tue Feb 10, 2015 1:33 pm
Location: Poland

Re: Generate certificates & keys for clients

Post by arturk » Tue Feb 10, 2015 6:33 pm

Code: Select all

C:\Program Files\OpenVPN\easy-rsa>build-key wiewiora
WARNING: can't open config file: /etc/ssl/openssl.cnf
error on line 99 of openssl-1.0.0.cnf
1672:error:0E065068:configuration file routines:STR_COPY:variable has no value:c
onf_def.c:618:line 99
WARNING: can't open config file: /etc/ssl/openssl.cnf
Using configuration from openssl-1.0.0.cnf
error on line 99 of config file 'openssl-1.0.0.cnf'
4024:error:0E065068:configuration file routines:STR_COPY:variable has no value:c
onf_def.c:618:line 99
Nie można odnaleźć C:\Program Files\OpenVPN\easy-rsa\keys\*.old.

C:\Program Files\OpenVPN\easy-rsa>

User avatar
maikcat
Forum Team
Posts: 4200
Joined: Wed Jan 12, 2011 9:23 am
Location: Athens,Greece
Contact:

Re: Generate certificates & keys for clients

Post by maikcat » Wed Feb 11, 2015 6:41 am

did you run vars.bat?

Michael.

arturk
OpenVpn Newbie
Posts: 7
Joined: Tue Feb 10, 2015 1:33 pm
Location: Poland

Re: Generate certificates & keys for clients

Post by arturk » Wed Feb 11, 2015 7:19 am

maikcat wrote:did you run vars.bat?
Michael.
Yep :|

User avatar
maikcat
Forum Team
Posts: 4200
Joined: Wed Jan 12, 2011 9:23 am
Location: Athens,Greece
Contact:

Re: Generate certificates & keys for clients

Post by maikcat » Wed Feb 11, 2015 9:39 am

can you post the contents of build-key.bat file?

Michael.

arturk
OpenVpn Newbie
Posts: 7
Joined: Tue Feb 10, 2015 1:33 pm
Location: Poland

Re: Generate certificates & keys for clients

Post by arturk » Wed Feb 11, 2015 6:03 pm

maikcat wrote:can you post the contents of build-key.bat file?

Michael.
build-key.bat

Code: Select all

@echo off
cd %HOME%
rem build a request for a cert that will be valid for ten years
openssl req -days 3650 -nodes -new -keyout %KEY_DIR%\%1.key -out %KEY_DIR%\%1.csr -config %KEY_CONFIG%
rem sign the cert request with our ca, creating a cert/key pair
openssl ca -days 3650 -out %KEY_DIR%\%1.crt -in %KEY_DIR%\%1.csr -config %KEY_CONFIG%
rem delete any .old files created in this process, to avoid future file creation errors
del /q %KEY_DIR%\*.old

User avatar
maikcat
Forum Team
Posts: 4200
Joined: Wed Jan 12, 2011 9:23 am
Location: Athens,Greece
Contact:

Re: Generate certificates & keys for clients

Post by maikcat » Thu Feb 12, 2015 7:16 am

can you check and see what are the content of openssl-1.0.0.cnf at line 99?

because in my pc this line is empty...

can you check if there is a tab there?

Michael.

arturk
OpenVpn Newbie
Posts: 7
Joined: Tue Feb 10, 2015 1:33 pm
Location: Poland

Re: Generate certificates & keys for clients

Post by arturk » Thu Feb 12, 2015 8:13 pm

maikcat wrote:can you check and see what are the content of openssl-1.0.0.cnf at line 99?
Michael.
line 99:
localityName_default = $ENV::KEY_CITY

User avatar
maikcat
Forum Team
Posts: 4200
Joined: Wed Jan 12, 2011 9:23 am
Location: Athens,Greece
Contact:

Re: Generate certificates & keys for clients

Post by maikcat » Mon Feb 16, 2015 11:28 am

just curious,

because easy-rsa is not part of openvpn anymore,where did you get it?

Michael.

arturk
OpenVpn Newbie
Posts: 7
Joined: Tue Feb 10, 2015 1:33 pm
Location: Poland

Re: Generate certificates & keys for clients

Post by arturk » Tue Feb 17, 2015 7:07 am

maikcat wrote:just curious,
I know... anyway I recreated all certificates, so I'm done for now. Thanks for your effort.
because easy-rsa is not part of openvpn anymore,where did you get it?
Michael.
From github, exactly from here AFIR -> https://github.com/OpenVPN/easy-rsa/blo ... -1.0.0.cnf

User avatar
maikcat
Forum Team
Posts: 4200
Joined: Wed Jan 12, 2011 9:23 am
Location: Athens,Greece
Contact:

Re: Generate certificates & keys for clients

Post by maikcat » Tue Feb 17, 2015 9:03 am

localityName_default appears in line 127 not in 99.... :?

since you solved your problem its ok..

regards,

Michael.

Post Reply