8

I am attempting to connect to a service using OpenVPN.

There are a number of configuration files (.OVPN) that share a single certificate (ca.crt); all are located in the same directory. Canada.ovpn, for example:

client
dev tun
proto udp
remote ca.#########.com 443
resolv-retry 5
nobind
fast-io
float
tun-mtu 1500
tun-mtu-extra 32
mssfix 1450
persist-key
persist-tun
ca ca.crt
auth-user-pass
comp-lzo
route-delay 5 30
script-security 3 system
ping-restart 0
mute-replay-warnings
verb 3

When I attempt to connect:

sudo openvpn --config ./configs/canada.ovpn --auth-user-pass ./credentials.txt

I get an error that reads:

Options error: --ca fails with 'ca.crt': No such file or directory Options error: Please correct these errors. Use --help for more information.

It seems that openvpn is having difficultly with the relative path. I changed the relevant line to ca ./ca.crt, but that resulted in the same error.

Configuration files that have an in-line certificate work as expected.

What is the correct way to use a relative path to a certificate in an .OVPN file?

craibuc
  • 467
  • 2
  • 5
  • 15
  • Where is the file `ca.crt` located? One directory up from where `canada.ovpn` is, as the config and command line suggests? – Håkan Lindqvist Nov 09 '14 at 19:39
  • It is also located in the `configs` directory (i.e. with the `*.ovpn` files). – craibuc Nov 09 '14 at 19:47
  • Ok, good to have that confirmed. Then I believe my answer should have you covered both in terms of what is the current problem and how `--cd` is likely the road to sanity. – Håkan Lindqvist Nov 09 '14 at 19:59

1 Answers1

15

It appears that the referenced file does not exist in the current working directory.

Is your intention to reference a file that is also in the same directory as the config (.ovpn) file? If so, based on your command line, it does not appear that these files are actually in ./ but rather in configs/.

As a better approach, I believe you may want to use the --cd option to have openvpn change working directories before opening any files.

Håkan Lindqvist
  • 35,011
  • 5
  • 69
  • 94
  • 1
    That worked. Needed to move the credentials file (cred.txt) to the same directory. Working command: `sudo openvpn --cd /etc/certificates/configs --config canada.ovpn --auth-user-pass ./cred.txt` – craibuc Nov 10 '14 at 13:12