Skip to content

Instantly share code, notes, and snippets.

@KenjiOhtsuka
Created August 14, 2023 05:39
Show Gist options
  • Save KenjiOhtsuka/2fb7652f82e849fc57ce423ec493224a to your computer and use it in GitHub Desktop.
Save KenjiOhtsuka/2fb7652f82e849fc57ce423ec493224a to your computer and use it in GitHub Desktop.
PEM key variation

秘密鍵の形式ごとに、使用するクラスが違う(C#)

“BEGIN RSA PRIVATE KEY” => RSA.ImportRSAPrivateKey
“BEGIN PRIVATE KEY” => RSA.ImportPkcs8PrivateKey
“BEGIN ENCRYPTED PRIVATE KEY” => RSA.ImportEncryptedPkcs8PrivateKey
“BEGIN RSA PUBLIC KEY” => RSA.ImportRSAPublicKey
“BEGIN PUBLIC KEY” => RSA.ImportSubjectPublicKeyInfo

https://stackoverflow.com/questions/70132574/asn1-corrupted-data-error-when-replacing-public-key-but-not-private-key

これらの鍵の規格については、PKCSで定義されている。 https://zenn.dev/htlsne/articles/rsa-key-format

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment