aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorAdnan Maolood <[email protected]>2020-10-28 13:47:52 -0400
committerAdnan Maolood <[email protected]>2020-10-28 13:47:52 -0400
commit32f22a3e2c6f4430bdee25b5cc7e14063075a07d (patch)
tree3f6548b579fc556919ee040019b05c3bc3ecc0a4 /examples
parentRefactor client certificates (diff)
downloadgo-gemini-32f22a3e2c6f4430bdee25b5cc7e14063075a07d.tar.xz
go-gemini-32f22a3e2c6f4430bdee25b5cc7e14063075a07d.zip
Fix examples/cert.go
Diffstat (limited to 'examples')
-rw-r--r--examples/cert.go18
1 files 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)
}