Pārlūkot izejas kodu

fix #898

tags/v2.1.0-rc1
Shivaram Lingamneni 4 gadus atpakaļ
vecāks
revīzija
f2da69d49f
1 mainītis faili ar 8 papildinājumiem un 6 dzēšanām
  1. 8
    6
      irc/mkcerts/certs.go

+ 8
- 6
irc/mkcerts/certs.go Parādīt failu

4
 package mkcerts
4
 package mkcerts
5
 
5
 
6
 import (
6
 import (
7
-	"crypto/ecdsa"
8
-	"crypto/elliptic"
9
 	"crypto/rand"
7
 	"crypto/rand"
8
+	"crypto/rsa"
10
 	"crypto/x509"
9
 	"crypto/x509"
11
 	"crypto/x509/pkix"
10
 	"crypto/x509/pkix"
12
 	"encoding/pem"
11
 	"encoding/pem"
23
 	validFor := 365 * 24 * time.Hour
22
 	validFor := 365 * 24 * time.Hour
24
 	notAfter := validFrom.Add(validFor)
23
 	notAfter := validFrom.Add(validFor)
25
 
24
 
26
-	priv, err := ecdsa.GenerateKey(elliptic.P521(), rand.Reader)
25
+	priv, err := rsa.GenerateKey(rand.Reader, 2048)
26
+	if err != nil {
27
+		return
28
+	}
27
 
29
 
28
 	serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128)
30
 	serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128)
29
 	serialNumber, err := rand.Int(rand.Reader, serialNumberLimit)
31
 	serialNumber, err := rand.Int(rand.Reader, serialNumberLimit)
59
 
61
 
60
 	certBytes = pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: derBytes})
62
 	certBytes = pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: derBytes})
61
 
63
 
62
-	b, err := x509.MarshalECPrivateKey(priv)
64
+	b, err := x509.MarshalPKCS8PrivateKey(priv)
63
 	if err != nil {
65
 	if err != nil {
64
-		return nil, nil, fmt.Errorf("Unable to marshal ECDSA private key: %v", err.Error())
66
+		return nil, nil, fmt.Errorf("Unable to marshal private key: %v", err.Error())
65
 	}
67
 	}
66
-	pemBlock := pem.Block{Type: "EC PRIVATE KEY", Bytes: b}
68
+	pemBlock := pem.Block{Type: "PRIVATE KEY", Bytes: b}
67
 	keyBytes = pem.EncodeToMemory(&pemBlock)
69
 	keyBytes = pem.EncodeToMemory(&pemBlock)
68
 	return certBytes, keyBytes, nil
70
 	return certBytes, keyBytes, nil
69
 }
71
 }

Notiek ielāde…
Atcelt
Saglabāt