1
0
Fork 0
mirror of https://github.com/Luzifer/vault-openvpn.git synced 2024-12-24 13:51:22 +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"
"os"
"path"
"strconv"
"strings"
"text/template"
"time"
@ -238,19 +237,14 @@ func validateSerial(serial string) bool {
return len(strings.Split(serial, ":")) > 1
}
func generateDHParam(name string, v ...string) (interface{}, error) {
bits, err := strconv.Atoi(name)
if err != nil {
return nil, fmt.Errorf("Unable to parse bit size: %s", err)
}
var generator int = 2
func generateDHParam(bits int, v ...int) (interface{}, error) {
var (
err error
generator int = 2
)
if len(v) > 0 {
if generator, err = strconv.Atoi(v[0]); err != nil {
return nil, fmt.Errorf("Unable to parse generator: %s", err)
}
generator = v[0]
if generator != 2 && generator != 5 {
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 string(p), nil
return strings.TrimSpace(string(p)), nil
}