aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
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)
}