Fix occur panic when invalid PublicKey parsing.
This commit is contained in:
@ -25,6 +25,9 @@ func ReadPrivateKeyRSAfromPath(path string) (*rsa.PrivateKey, error) {
|
||||
func ReadPublicKeyRSAfromString(pemString string) (*rsa.PublicKey, error) {
|
||||
pemByte := []byte(pemString)
|
||||
decoded, _ := pem.Decode(pemByte)
|
||||
defer func() {
|
||||
recover()
|
||||
}()
|
||||
keyInterface, err := x509.ParsePKIXPublicKey(decoded.Bytes)
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
|
Reference in New Issue
Block a user