mirror of
https://github.com/jech/galene.git
synced 2024-11-14 04:35:57 +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/rsa"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
|
"errors"
|
||||||
"log"
|
"log"
|
||||||
"math/big"
|
"math/big"
|
||||||
"os"
|
"os"
|
||||||
|
@ -73,7 +74,11 @@ func getCertificate(dataDir string) (*tls.Certificate, error) {
|
||||||
|
|
||||||
if !ok || !info.certTime.Equal(certTime) || !info.keyTime.Equal(keyTime) {
|
if !ok || !info.certTime.Equal(certTime) || !info.keyTime.Equal(keyTime) {
|
||||||
var cert tls.Certificate
|
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")
|
log.Printf("Generating self-signed certificate")
|
||||||
var err error
|
var err error
|
||||||
cert, err = generateCertificate(dataDir)
|
cert, err = generateCertificate(dataDir)
|
||||||
|
|
Loading…
Reference in a new issue