Add auth interceptor
This commit is contained in:
@@ -104,7 +104,7 @@ func GenAllCerts(path, domain string) error {
|
||||
|
||||
// Create server certs
|
||||
dnsNames := []string{domain}
|
||||
srvKey, srvCrt, err := GenCert(caPub, caPriv, dnsNames)
|
||||
srvKey, srvCrt, err := GenCert("server", caPub, caPriv, dnsNames)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -115,7 +115,7 @@ func GenAllCerts(path, domain string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
clientKey, clientCrt, err := GenCert(caPub, caPriv, []string{})
|
||||
clientKey, clientCrt, err := GenCert("client", caPub, caPriv, []string{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -129,7 +129,7 @@ func GenAllCerts(path, domain string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func GenCert(caPub, caPrivKey []byte, dnsNames []string) (priv, pub []byte, err error) {
|
||||
func GenCert(cn string, caPub, caPrivKey []byte, dnsNames []string) (priv, pub []byte, err error) {
|
||||
// Parse ca
|
||||
ca, err := x509.ParseCertificate(caPub)
|
||||
if err != nil {
|
||||
@@ -144,6 +144,7 @@ func GenCert(caPub, caPrivKey []byte, dnsNames []string) (priv, pub []byte, err
|
||||
cert := &x509.Certificate{
|
||||
SerialNumber: big.NewInt(time.Now().Unix()),
|
||||
Subject: pkix.Name{
|
||||
CommonName: cn,
|
||||
Organization: []string{"ezshare"},
|
||||
Country: []string{"No"},
|
||||
Locality: []string{"Oslo"},
|
||||
|
Reference in New Issue
Block a user