mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Merge pull request #35323 from mikkeloscar/decode-pem
Automatic merge from submit-queue ssh pubkey parsing: prevent segfault
This commit is contained in:
commit
2cd42b1bdb
@ -277,6 +277,9 @@ func ParsePublicKeyFromFile(keyFile string) (*rsa.PublicKey, error) {
|
||||
return nil, fmt.Errorf("error reading SSH key %s: '%v'", keyFile, err)
|
||||
}
|
||||
keyBlock, _ := pem.Decode(buffer)
|
||||
if keyBlock == nil {
|
||||
return nil, fmt.Errorf("error parsing SSH key %s: 'invalid PEM format'", keyFile)
|
||||
}
|
||||
key, err := x509.ParsePKIXPublicKey(keyBlock.Bytes)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error parsing SSH key %s: '%v'", keyFile, err)
|
||||
|
Loading…
Reference in New Issue
Block a user