I have been trying to make a very basic OpenVPN client wrapper. I have made it connect to a server using the ovpn file and some start parameters, but I want to do this without a written file because my program has the connection file's text. Is there any way for me to connect without having to write a temporary ovpn file?
This is what I have currently:
string ServerFileContents = "...";
string UserPassContents = "...";
File.WriteAllText("server.ovpn", ServerFileContents);
File.WriteAllText("userpass.txt", UserPassContents);
string args = "--config server.ovpn --auth-user-pass userpass.txt";
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new
System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = @"C:\Program Files\OpenVPN\bin\openvpn.exe";
startInfo.Arguments = args;
startInfo.Verb = "runas";
process.StartInfo = startInfo;
process.Start();
Ideally, I would do something like (I know this wouldn't actually work, I'm just trying to show my point):
string args = "--configcontents " + ServerFileContents + " --auth-user-pass-contents " + UserPassContents;