Skip to content

Instantly share code, notes, and snippets.

@svolobuev
Created May 25, 2020 20:55
Show Gist options
  • Save svolobuev/4489f4735634f5e7f685274b9f8d5b39 to your computer and use it in GitHub Desktop.
Save svolobuev/4489f4735634f5e7f685274b9f8d5b39 to your computer and use it in GitHub Desktop.
ssh.PublicKey cast to rsa.PublicKey
package rsa
import (
"crypto/rsa"
"golang.org/x/crypto/ssh"
)
func FromSshPublicKey(key ssh.PublicKey) (*rsa.PublicKey, bool) {
if cryptoKey, ok := key.(ssh.CryptoPublicKey); ok {
rsaKey, ok := cryptoKey.CryptoPublicKey().(*rsa.PublicKey)
return rsaKey, ok
}
return nil, false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment