From 32f22a3e2c6f4430bdee25b5cc7e14063075a07d Mon Sep 17 00:00:00 2001 From: Adnan Maolood Date: Wed, 28 Oct 2020 13:47:52 -0400 Subject: [PATCH] Fix examples/cert.go --- examples/cert.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/examples/cert.go b/examples/cert.go index 9ab80af..9d04cd8 100644 --- a/examples/cert.go +++ b/examples/cert.go @@ -7,6 +7,7 @@ import ( "crypto/tls" "crypto/x509" "encoding/pem" + "fmt" "log" "os" "time" @@ -15,9 +16,20 @@ import ( ) func main() { - host := "localhost" - duration := 365 * 24 * time.Hour - cert, err := gemini.NewCertificate(host, duration) + if len(os.Args) < 3 { + fmt.Printf("usage: %s [hostname] [duration]\n", os.Args[0]) + os.Exit(1) + } + host := os.Args[1] + duration, err := time.ParseDuration(os.Args[2]) + if err != nil { + log.Fatal(err) + } + options := gemini.CertificateOptions{ + DNSNames: []string{host}, + Duration: duration, + } + cert, err := gemini.CreateCertificate(options) if err != nil { log.Fatal(err) }