How to export a password-protected private key using MS CryptoAPI?
问题 Using Microsoft CryptoAPI, I've generated a new RSA key pair, and am now trying to export the private key to a PKCS#8 encrypted (password-protected) PEM file. I first investigated CryptExportPKCS8() and CryptExportPKCS8Ex(), but the former doesn't support encrypting the key, and the latter is not exported by crypt32.dll. MSDN says that both functions have been deprecated anyway. My current attempt is to pass a session key derived from the password to CryptExportKey(): HCRYPTPROV provider;