generated from things-labs/cicd-go-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rsa_file.go
63 lines (55 loc) · 1.39 KB
/
rsa_file.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package cert4go
import (
"crypto/rsa"
"crypto/x509"
"os"
)
func LoadRSAPKCS1PrivateKeyFromPEMFile(name string) (*rsa.PrivateKey, error) {
keyData, err := os.ReadFile(name)
if err != nil {
return nil, err
}
return ParseRSAPKCS1PrivateKeyFromPEM(keyData)
}
func LoadRSAPKCS8PrivateKeyFromPEMFile(name string) (*rsa.PrivateKey, error) {
keyData, err := os.ReadFile(name)
if err != nil {
return nil, err
}
return ParseRSAPKCS8PrivateKeyFromPEM(keyData)
}
func LoadRSAPrivateKeyFromPEMFile(name string) (*rsa.PrivateKey, error) {
keyData, err := os.ReadFile(name)
if err != nil {
return nil, err
}
return ParseRSAPrivateKeyFromPEM(keyData)
}
func LoadRSAPrivateKeyFromFile(name string) (*rsa.PrivateKey, error) {
keyData, err := os.ReadFile(name)
if err != nil {
return nil, err
}
return ParseRSAPrivateKey(keyData)
}
func LoadRSAPublicKeyFromPEMFile(name string) (*rsa.PublicKey, error) {
keyData, err := os.ReadFile(name)
if err != nil {
return nil, err
}
return ParseRSAPublicKeyFromPEM(keyData)
}
func LoadRSAPublicKeyFromFile(name string) (*rsa.PublicKey, error) {
keyData, err := os.ReadFile(name)
if err != nil {
return nil, err
}
return ParseRSAPublicKey(keyData)
}
func LoadPfxFromFile(name, password string) (*rsa.PrivateKey, *x509.Certificate, error) {
keyData, err := os.ReadFile(name)
if err != nil {
return nil, nil, err
}
return ParsePfx(keyData, password)
}