简体   繁体   中英

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. 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:

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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