We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9264a14 commit 7e0750bCopy full SHA for 7e0750b
1 file changed
1.7/client/crypto.go
@@ -0,0 +1,21 @@
1
+package utils
2
+
3
+import (
4
+ "crypto/rsa"
5
+ "crypto/x509"
6
+ "encoding/pem"
7
+ "fmt"
8
+ "io/ioutil"
9
+)
10
11
+func LoadPrivateKey(path string) (*rsa.PrivateKey, error) {
12
+ keyData, err := ioutil.ReadFile(path)
13
+ if err != nil {
14
+ return nil, err
15
+ }
16
+ block, _ := pem.Decode(keyData)
17
+ if block == nil || block.Type != "RSA PRIVATE KEY" {
18
+ return nil, fmt.Errorf("invalid private key data")
19
20
+ return x509.ParsePKCS1PrivateKey(block.Bytes)
21
+}
0 commit comments