Add ability to autogen self-signed x509 certs for use with Grumble.

This commit is contained in:
Mikkel Krautz 2011-04-28 20:27:38 +02:00
parent f36ae37afd
commit 1cc9745727
4 changed files with 105 additions and 3 deletions

View file

@ -9,13 +9,14 @@ import (
"encoding/pem"
"crypto/x509"
"io/ioutil"
"path/filepath"
)
func NewTLSListener(port int) (rl *tls.Listener) {
rl = nil
// Load the certificate
pemBytes, err := ioutil.ReadFile("grumble.crt")
pemBytes, err := ioutil.ReadFile(filepath.Join(*datadir, "cert"))
if err != nil {
log.Printf("Failed to read server.crt: %s", err)
return
@ -29,7 +30,7 @@ func NewTLSListener(port int) (rl *tls.Listener) {
}
// Load the private key
keyBytes, err := ioutil.ReadFile("grumble.key")
keyBytes, err := ioutil.ReadFile(filepath.Join(*datadir, "key"))
if err != nil {
log.Printf("Failed to read server.key.insecure: %s", err)
return