1
0
Fork 0
mirror of https://github.com/Luzifer/vault-openvpn.git synced 2024-11-09 16:50:04 +00:00

Fix: Parameters are not strings

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2018-10-08 13:36:45 +02:00
parent fd9a68bdd8
commit 0aa62f532c
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E

View file

@ -9,7 +9,6 @@ import (
"io/ioutil" "io/ioutil"
"os" "os"
"path" "path"
"strconv"
"strings" "strings"
"text/template" "text/template"
"time" "time"
@ -238,19 +237,14 @@ func validateSerial(serial string) bool {
return len(strings.Split(serial, ":")) > 1 return len(strings.Split(serial, ":")) > 1
} }
func generateDHParam(name string, v ...string) (interface{}, error) { func generateDHParam(bits int, v ...int) (interface{}, error) {
bits, err := strconv.Atoi(name) var (
if err != nil { err error
return nil, fmt.Errorf("Unable to parse bit size: %s", err) generator int = 2
} )
var generator int = 2
if len(v) > 0 { if len(v) > 0 {
if generator, err = strconv.Atoi(v[0]); err != nil { generator = v[0]
return nil, fmt.Errorf("Unable to parse generator: %s", err)
}
if generator != 2 && generator != 5 { if generator != 2 && generator != 5 {
return nil, errors.New("Only generators 2 and 5 are supported") return nil, errors.New("Only generators 2 and 5 are supported")
} }
@ -266,5 +260,5 @@ func generateDHParam(name string, v ...string) (interface{}, error) {
return nil, fmt.Errorf("Unable to encode DH parameters: %s", err) return nil, fmt.Errorf("Unable to encode DH parameters: %s", err)
} }
return string(p), nil return strings.TrimSpace(string(p)), nil
} }