Skip to content

Commit

Permalink
Improves the experiences by automatically selecting certs in the UI
Browse files Browse the repository at this point in the history
  • Loading branch information
dolanor committed Dec 18, 2015
1 parent df282d9 commit 35bdf43
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 34 deletions.
28 changes: 0 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ file.ovpn.tls-auth.pem

### Configure NetworkManager


#### Add a new network
![add-net](doc/01-add-net.png)

Expand All @@ -34,39 +33,12 @@ file.ovpn.tls-auth.pem
#### Select the file
![select-ovpn-file](doc/03-select-ovpn-file.png)

#### Choose a user cert file
![click-user-cert](doc/04-click-user-cert.png)

#### Select the file
![select-user-cert](doc/05-select-user-cert.png)

#### Choose a CA cert file
![click-ca-cert](doc/06-click-ca-cert.png)

#### Select the file
![select-ca-cert](doc/07-select-ca-cert.png)

#### Choose a key file
![select-private-key](doc/08-select-private-key.png)

#### Select the file
![select-private-key](doc/09-select-private-key.png)

#### Open the advanced config panel
![advanced-config](doc/10-advanced-config.png)

#### Go to TLS Auth Tab
![tls-auth](doc/11-tls-auth.png)

#### Add a optional TLS authentication
![add-tls-auth-file](doc/12-add-tls-auth-file.png)

#### Choose a tls-auth file
![choose-tls-auth-file](doc/13-choose-tls-auth-file.png)

#### Select the file
![select-tls-auth-file](doc/14-select-tls-auth-file.png)

#### Set the key direction
![set-key-direction](doc/15-set-key-direction.png)

Expand Down
Binary file removed doc/04-click-user-cert.png
Binary file not shown.
Binary file removed doc/05-select-user-cert.png
Binary file not shown.
Binary file removed doc/06-click-ca-cert.png
Binary file not shown.
Binary file removed doc/07-select-ca-cert.png
Binary file not shown.
Binary file removed doc/08-select-private-key.png
Binary file not shown.
Binary file removed doc/09-select-private-key.png
Binary file not shown.
Binary file removed doc/12-add-tls-auth-file.png
Binary file not shown.
Binary file removed doc/13-choose-tls-auth-file.png
Binary file not shown.
Binary file removed doc/14-select-tls-auth-file.png
Binary file not shown.
20 changes: 14 additions & 6 deletions ovpnsplit.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@ import (
"io/ioutil"
"log"
"os"
"path"
)

type Lol struct {
XMLName xml.Name `xml:"lol"`
Content string `xml:",chardata"`
OpenVPNData
}

type OpenVPNData struct {
Key string `xml:"key"`
Cert string `xml:"cert"`
Expand All @@ -31,24 +36,27 @@ func main() {
os.Exit(2)
}

data := OpenVPNData{}
data := Lol{}
// Ugly hack. Otherwise, not considered as xml valid…
filedata = append(append([]byte("<lol>\n"), filedata...), []byte("\n</lol>")...)
xml.Unmarshal(filedata, &data)

if data.Key != "" {
ioutil.WriteFile(path.Base(filepath)+".key.pem", []byte(data.Key), 0600)
ioutil.WriteFile(filepath+".key.pem", []byte(data.Key), 0600)
}

if data.Cert != "" {
ioutil.WriteFile(path.Base(filepath)+".cert.pem", []byte(data.Cert), 0600)
ioutil.WriteFile(filepath+".cert.pem", []byte(data.Cert), 0600)
}

if data.Ca != "" {
ioutil.WriteFile(path.Base(filepath)+".ca.pem", []byte(data.Ca), 0600)
ioutil.WriteFile(filepath+".ca.pem", []byte(data.Ca), 0600)
}

if data.TlsAuth != "" {
ioutil.WriteFile(path.Base(filepath)+".tls-auth.pem", []byte(data.TlsAuth), 0600)
ioutil.WriteFile(filepath+".tls-auth.pem", []byte(data.TlsAuth), 0600)
}

newnetmanfiledata := append(append(append(append([]byte(data.Content), []byte("\ncert "+filepath+".cert.pem\n")...), []byte("ca "+filepath+".ca.pem\n")...), []byte("key "+filepath+".key.pem\n")...), []byte("tls-auth "+filepath+".tls-auth.pem\n")...)
ioutil.WriteFile(filepath+".new.ovpn", newnetmanfiledata, 0600)
}

0 comments on commit 35bdf43

Please sign in to comment.