mirror of
https://github.com/jech/galene.git
synced 2024-11-09 18:25:58 +01:00
Fail the connection if only one of cert.pem and key.pem exists.
This commit is contained in:
parent
b1babf5b77
commit
c19b356e54
1 changed files with 6 additions and 1 deletions
|
@ -5,6 +5,7 @@ import (
|
|||
"crypto/rsa"
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"errors"
|
||||
"log"
|
||||
"math/big"
|
||||
"os"
|
||||
|
@ -73,7 +74,11 @@ func getCertificate(dataDir string) (*tls.Certificate, error) {
|
|||
|
||||
if !ok || !info.certTime.Equal(certTime) || !info.keyTime.Equal(keyTime) {
|
||||
var cert tls.Certificate
|
||||
if certTime.Equal(time.Time{}) || keyTime.Equal(time.Time{}) {
|
||||
nocert := certTime.Equal(time.Time{})
|
||||
nokey := keyTime.Equal(time.Time{})
|
||||
if nocert != nokey {
|
||||
return nil, errors.New("only one of cert.pem and key.pem exists")
|
||||
} else if nokey {
|
||||
log.Printf("Generating self-signed certificate")
|
||||
var err error
|
||||
cert, err = generateCertificate(dataDir)
|
||||
|
|
Loading…
Reference in a new issue