简体   繁体   English

如何在iOS中以SSL证书的字符串格式获取公钥

[英]How to get the Public key in string format of a SSL certificate in ios

I can get the public key of SSL certificate using SecTrustCopyPublicKey. 我可以使用SecTrustCopyPublicKey获取SSL证书的公钥。 But how can get the Public key in string format? 但是如何获取字符串格式的公钥?

if you want to save public key ec curve name, you can use this function: 如果要保存公钥ec曲线名称,可以使用以下功能:

string public_key_ec_curve_name(X509 *x509)
{ 
    EVP_PKEY *pkey = X509_get_pubkey(x509);
    int key_type = EVP_PKEY_type(pkey->type);
    if (key_type == EVP_PKEY_EC)
    {
        cont EC_GROUP* group = EC_KEY_GET0_group(pkey->pkey.ec);
        int name = (group != NULL) ? EC_GROUP_get_curve_name(group) : 0;
        return name ? OBJ_nid2sn(name) : ";
    }
    return "";
}

it saves the public ec curve name in string format. 它以字符串格式保存公共EC曲线名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM