mirror of
https://github.com/Luzifer/vault-openvpn.git
synced 2024-12-25 14:21:21 +00:00
Fix: Parameters are not strings
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
fd9a68bdd8
commit
0aa62f532c
1 changed files with 7 additions and 13 deletions
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue