Windows が証明書をダブルクリックしたときと同じように、公開鍵を表示する必要があります (画像を参照)。ありがとう。
次のいずれかで公開鍵を取得できます。
RSA *pubKey = X509_get_pubkey( csc->current_cert )->pkey.rsa;
また
EVP_PKEY *pubKey = X509_get_pubkey(csc->current_cert);
このスニペットがどこかで見つかったが、取得した値が Windows が表示するものと異なる場合:
unsigned char enc_bin[1024] = {0};
int enc_len = 0;
unsigned char dec_bin[1024] = {0};
int dec_len = 0;
enc_len = RSA_size( pubKey );
memset( enc_bin, 1, enc_len );
if( 0 < ( dec_len = RSA_public_decrypt( enc_len, enc_bin, dec_bin, pubKey, RSA_NO_PADDING) ) )
{
for (int i = 0; i < dec_len; i++)
{
CString str;
if( 0 == i )
str.Format( L"%02X", dec_bin[i] );
else
str.Format( L" %02X", dec_bin[i] );
PubKey += str;
}
}