OpenVPN error : Options error: Unrecognized option or missing or extra parameter

networkingopenvpnvpn

I have a ovpn file with following format.

client
dev tun
proto udp
remote MY_IP 1194
resolv-retry infinite
nobind
persist-key
persist-tun
mute-replay-warnings
ns-cert-type server
key-direction 1 
cipher AES-128-CBC
comp-lzo
verb 1
mute 20

-----BEGIN CERTIFICATE-----
M---DeletedContent
+Jl7
-----END CERTIFICATE-----


-----BEGIN CERTIFICATE-----
DeletedContentYsuN5d
-----END CERTIFICATE-----


-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,EB9C4DDDD26848F5

PDeletedContent
-----END RSA PRIVATE KEY-----


#
# 2048 bit OpenVPN static key
#
-----BEGIN OpenVPN Static key V1-----
DeletedContent
-----END OpenVPN Static key V1-----

When I am trying to open this with OVPN 2.4.4 getting following error:

Options error: Unrecognized option or missing or extra parameter(s) in C:\Users\Stevens\Desktop\user01.ovpn:17: —BEGIN (2.4.4)
Use –help for more information.
Press any key to continue…

Line 17 is the 1st —–BEGIN CERTIFICATE—–. What am I doing wrong??

Best Answer

You need to wrap your certs in suitable block directives, my similar file has this structure

...
<ca>
-----BEGIN CERTIFICATE-----
... 
-----END CERTIFICATE-----
</ca>
<cert>
-----BEGIN CERTIFICATE-----
... 
-----END CERTIFICATE-----
</cert>
<key>
-----BEGIN PRIVATE KEY-----
....
-----END PRIVATE KEY-----
</key>
<tls-auth>
#
# 2048 bit OpenVPN static key
#
-----BEGIN OpenVPN Static key V1-----
...
-----END OpenVPN Static key V1-----
</tls-auth>