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
|
func parsingRsaPublicKey(file string) (*rsa.PublicKey, error) { pubByte,err := ioutil.ReadFile(file) if err != nil { return nil,err } b,_ := pem.Decode(pubByte) if b == nil { return nil,errors.New("error public key") } pubKey,err := x509.ParsePKCS1PublicKey(b.Bytes) if err != nil { return nil,err } return pubKey,nil }
func parsingRsaPrivateKey(file string) (*rsa.PrivateKey, error) { priByte,err := ioutil.ReadFile(file) if err != nil { return nil,err } b,_ := pem.Decode(priByte) if b == nil { return nil,errors.New("error private key") } prikey,err := x509.ParsePKCS1PrivateKey(b.Bytes) if err != nil { return nil,err } return prikey,nil }
|