Browse Source

feature: just display cert key instead of pem to save space

make_cert_optional
Otto Suess 7 years ago
parent
commit
83e1b921c0
No known key found for this signature in database GPG Key ID: 354749C62B4BAC41
  1. 14
      zapconnect.go

14
zapconnect.go

@ -10,6 +10,7 @@ b64 "encoding/base64"
"net/http" "net/http"
"os" "os"
"strings" "strings"
"encoding/pem"
) )
type certificates struct { type certificates struct {
@ -63,13 +64,20 @@ func main() {
return return
} }
block, _ := pem.Decode(certBytes)
if block == nil || block.Type != "CERTIFICATE" {
fmt.Println("failed to decode PEM block containing certificate")
}
certificate := b64.StdEncoding.EncodeToString([]byte(block.Bytes))
macBytes, err := ioutil.ReadFile(loadedConfig.AdminMacPath) macBytes, err := ioutil.ReadFile(loadedConfig.AdminMacPath)
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
return return
} }
sEnc := b64.StdEncoding.EncodeToString([]byte(macBytes)) macaroonB64 := b64.StdEncoding.EncodeToString([]byte(macBytes))
ipString := "" ipString := ""
if loadedConfig.LocalIp { if loadedConfig.LocalIp {
@ -79,8 +87,8 @@ func main() {
} }
cert := &certificates{ cert := &certificates{
Cert: string(certBytes), Cert: certificate,
Macaroon: sEnc, Macaroon: macaroonB64,
Ip: ipString} Ip: ipString}
certB, _ := json.Marshal(cert) certB, _ := json.Marshal(cert)

Loading…
Cancel
Save