簡體   English   中英

如何在iOS中以SSL證書的字符串格式獲取公鑰

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

我可以使用SecTrustCopyPublicKey獲取SSL證書的公鑰。 但是如何獲取字符串格式的公鑰?

如果要保存公鑰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 "";
}

它以字符串格式保存公共EC曲線名稱。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM