How to fix the openvpn service Error opening configuration file on Windows 10

8,894

Solution 1

Finally the solution was desperately simple: remove the encrypt attribute on the file.

Apparently, openvpn as a command can decrypt the files, but as a service it cannot.

Solution 2

What is the command line the service uses to launch OpenVPN?

If it looks something like this:

openvpn C:\Program Files\OpenVPN\config\xxx.ovpn

OpenVPN (usually) needs to be launched in the directory where all of its authentication files are (unless you specified an absolute path to them; like C:\Program Files\OpenVPN\ta.key) Try adding --cd C:\Program Files\OpenVPN\ to the command line, so that it looks more like this:

openvpn --cd C:\Program Files\OpenVPN\ --config C:\Program Files\OpenVPN\config\xxx.ovpn

If that doesn't help, try adding --verb 11 to the command line and showing us the output of that.

EDIT

The OpenVPN page on Running OpenVPN as a Windows Service shows that the C:\Program Files\OpenVPN\bin\openvpnserv2.exe is a service wrapper that launches the main OpenVPN executable. I have two suggestions:

1:
Use regedit to show us the settings the wrapper is using (the page mentioned above has information on the registry values), and modify them appropriately.
2:
Write your own batch script that launches OpenVPN and set that as the executable launched by the service. I would prefer the former of these two, as it is the least invasive.

Share:
8,894

Related videos on Youtube

Alex
Author by

Alex

multilanguage developer multilingual project manager computer projects environmental management projects

Updated on September 18, 2022

Comments

  • Alex
    Alex over 1 year

    I experience a frustrating behaviour of openVPN used as a Windows 10 service:
    it doesn't start, and when you look at the log it tells:

    Options error: In [CMD-LINE]:1: Error opening configuration file: C:\Program Files\OpenVPN\config\xxx.ovpn
    Use --help for more information.
    

    But the openvpn GUI works with the same configuration file! Unfortunately, the --help doesn't help.
    What can I do to at least have more diagnostic details?
    Thanks
    Alexandre

    • montonero
      montonero over 5 years
      You could try Process Monitor to check why OpenVPN service can't open the file.
    • Alex
      Alex over 5 years
      Thanks Montonero. It is hard to decipher. I can see that bitdefenderis sometimes involved, but I cannot determine whether it is generating a conflict.
    • montonero
      montonero over 5 years
      You'll need to include only OpenVPN service process in a procmon's filter. That will make things much easier.
    • Alex
      Alex over 5 years
      I did initially, but unfortunatelly, it does not give me a better hint that the previous one regarding bitdefender. I can only suppose that bitdefender is restricting the access to the C:\Program Files\OpenVPN\config directory.
  • Alex
    Alex over 5 years
    Thanks Shadowcoder But there is no command line. It is launched as a service whose main executable is located at "C:\Program Files\OpenVPN\bin\openvpnserv2.exe". I suppose that the problem is related to some rights, but couldn't find out which.
  • Shadowcoder
    Shadowcoder over 5 years
    Looks like you might have to go poking around in the registry or reconfigure the service to launch OpenVPN without the service wrapper. Read my edits above
  • Alex
    Alex over 4 years
    Your answer helped me because I did some tries changing the file name in the registry. It guided me to look at the attributes of the config file, and when I removed the encrypt attribute, it worked. Thanks again Shadowcoder.