LDAP 検索要求から (base64 デコード後に) DER でエンコードされた証明書を取得しており、そこから公開鍵を解析する必要があります。私はopensslライブラリでそれが可能であると確信しています。残念ながら、API ドキュメントはあまり整備されていません。情報を抽出するための例や他のライブラリはありますか?
3944 次
2 に答える
2
Use d2i_X509 to get the certificate in X509 * structure. After that use X509_get_pubkey to get the public key. X509_get_pubkey will give you public key in EVP_PKEY * structure. I hope this must solve your purpose.
If your certificate is in PEM format (Base64 encoded wrapped by "-----BEGIN CERTIFICATE-----") , then you can also use PEM_read_X509 to get X509 * object directly.
Example:
//Get the X509 object.
//Say certificate is encoded in a file
X509 * xcert = PEM_read_X509(fp, NULL, NULL, NULL);
//or assuming DER encoded certificate in buf with length of buffer is buflen.
X509 * xcert = d2i_X509(NULL, buf, buflen);
//Get the public key.
EVP_PKEY * pubkey = X509_get_pubkey(xcert);
//later free this pubkey object when no longer required.
EVP_PKEY_free(pubkey);
于 2013-02-25T06:25:57.387 に答える
1
d2i_X509 API を使用して、DER でエンコードされた証明書のデコードを試みることができます。これにより、公開鍵を取得できる X509 構造が提供されます。
于 2013-02-25T06:17:54.430 に答える