DIsable use of specific cli flag for certificate and private key as strings
This commit is contained in:
parent
a556096cee
commit
330d834706
2 changed files with 17 additions and 13 deletions
29
cli/setup.go
29
cli/setup.go
|
@ -21,7 +21,6 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/abcum/surreal/log"
|
"github.com/abcum/surreal/log"
|
||||||
"github.com/abcum/surreal/util/cert"
|
|
||||||
"github.com/abcum/surreal/util/uuid"
|
"github.com/abcum/surreal/util/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -145,20 +144,26 @@ func setup() {
|
||||||
// Certs
|
// Certs
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
|
||||||
if opts.Cert.Pem != "" {
|
if strings.HasPrefix(opts.Cert.Crt, "-----") {
|
||||||
|
var err error
|
||||||
if opts.Cert.Key != "" || opts.Cert.Crt != "" {
|
var doc *os.File
|
||||||
log.Fatal("You can not specify --cert-pem with --cert-key or --cert-crt")
|
if doc, err = os.Create("cert.crt"); err != nil {
|
||||||
|
log.Fatal("Can not decode PEM encoded certificate into cert.crt")
|
||||||
}
|
}
|
||||||
|
doc.Write([]byte(opts.Cert.Crt))
|
||||||
err := cert.Extract(opts.Cert.Pem, "cert.key", "cert.crt")
|
doc.Close()
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
opts.Cert.Key = "cert.key"
|
|
||||||
opts.Cert.Crt = "cert.crt"
|
opts.Cert.Crt = "cert.crt"
|
||||||
|
}
|
||||||
|
|
||||||
|
if strings.HasPrefix(opts.Cert.Key, "-----") {
|
||||||
|
var err error
|
||||||
|
var doc *os.File
|
||||||
|
if doc, err = os.Create("cert.key"); err != nil {
|
||||||
|
log.Fatal("Can not decode PEM encoded private key into cert.key")
|
||||||
|
}
|
||||||
|
doc.Write([]byte(opts.Cert.Key))
|
||||||
|
doc.Close()
|
||||||
|
opts.Cert.Key = "cert.key"
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
|
|
@ -36,7 +36,6 @@ type Options struct {
|
||||||
Cert struct {
|
Cert struct {
|
||||||
Crt string // File location of server crt
|
Crt string // File location of server crt
|
||||||
Key string // File location of server key
|
Key string // File location of server key
|
||||||
Pem string // File location of server pem
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Auth struct {
|
Auth struct {
|
||||||
|
|
Loading…
Reference in a new issue