Implement certificate creation

This commit is contained in:
adnano
2020-09-27 13:50:48 -04:00
parent e28e547bcf
commit 2eb7fb9ba4
10 changed files with 159 additions and 33 deletions

22
examples/cert/cert.go Normal file
View File

@@ -0,0 +1,22 @@
// +build example
package main
import (
"log"
"git.sr.ht/~adnano/go-gemini"
)
func main() {
host := "localhost"
crt, key, err := gemini.NewCertificate(host)
if err != nil {
log.Fatal(err)
}
if err := gemini.WriteCertificate(host, crt, key); err != nil {
log.Fatal(err)
}
}

View File

@@ -1,2 +0,0 @@
client.crt
client.key

View File

@@ -59,7 +59,7 @@ func init() {
// openssl ecparam -genkey -name secp384r1 -out client.key
// openssl req -new -x509 -sha512 -key client.key -out client.crt -days 365
//
cert, err = tls.LoadX509KeyPair("examples/client/client.crt", "examples/client/client.key")
cert, err = tls.LoadX509KeyPair("examples/client/localhost.crt", "examples/client/localhost.key")
if err != nil {
log.Fatal(err)
}

View File

@@ -1,2 +0,0 @@
server.crt
server.key

View File

@@ -17,7 +17,7 @@ func main() {
// openssl ecparam -genkey -name secp384r1 -out server.key
// openssl req -new -x509 -sha512 -key server.key -out server.crt -days 365
//
cert, err := tls.LoadX509KeyPair("examples/server/server.crt", "examples/server/server.key")
cert, err := tls.LoadX509KeyPair("examples/server/localhost.crt", "examples/server/localhost.key")
if err != nil {
log.Fatal(err)
}