Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/118.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 下面的代码对于分离的签名非常有效!!如何获得附加签名?_Ios_Objective C_Security_Openssl_Openssl Engine - Fatal编程技术网

Ios 下面的代码对于分离的签名非常有效!!如何获得附加签名?

Ios 下面的代码对于分离的签名非常有效!!如何获得附加签名?,ios,objective-c,security,openssl,openssl-engine,Ios,Objective C,Security,Openssl,Openssl Engine,我最终得到的结果是分离签名,但我的要求是获得附加签名。我必须使用我的CSR文件进行签名,才能使用openssl获得附加签名。我浏览了很多网站,但没有人提供适当的解决方案 (NSData*)getSignature { unsigned char sha_buffer[SHA256_DIGEST_LENGTH]; memset((void*) sha_buffer, 0, SHA256_DIGEST_LENGTH); SHA256_Final(sha_buffer, &m_sha_ctx

我最终得到的结果是分离签名,但我的要求是获得附加签名。我必须使用我的CSR文件进行签名,才能使用openssl获得附加签名。我浏览了很多网站,但没有人提供适当的解决方案

(NSData*)getSignature
{

unsigned char sha_buffer[SHA256_DIGEST_LENGTH];
memset((void*) sha_buffer, 0, SHA256_DIGEST_LENGTH);
SHA256_Final(sha_buffer, &m_sha_ctx);

PKCS7 * p7 = PKCS7_new();
PKCS7_set_type(p7, NID_pkcs7_signed);

PKCS7_SIGNER_INFO* p7Si = PKCS7_add_signature(p7, mp_x509, mp_pkey, EVP_sha256());
PKCS7_add_attrib_content_type(p7Si, OBJ_nid2obj(NID_pkcs7_data));
PKCS7_add0_attrib_signing_time(p7Si, NULL);
PKCS7_add1_attrib_digest(p7Si, (const unsigned char*) sha_buffer, SHA256_DIGEST_LENGTH);
PKCS7_add_certificate(p7, mp_x509);

int c = 0;
for ( ; c < sk_X509_num(mp_ca); c++) {
    X509* cert = sk_X509_value(mp_ca, c);
    PKCS7_add_certificate(p7, cert);
}

PKCS7_set_detached(p7, 1);

PKCS7_content_new(p7, NID_pkcs7_data);

PKCS7_SIGNER_INFO_sign(p7Si);

int p7Len = i2d_PKCS7(p7, NULL);
NSMutableData* signature = [NSMutableData data];
unsigned char* p7Buf = (unsigned char*) malloc(p7Len);
if (p7Buf != NULL) {
    unsigned char* pP7Buf = p7Buf;
    i2d_PKCS7(p7, &pP7Buf);
    [signature appendBytes: (const void*) p7Buf length: p7Len];
    free(p7Buf);
}
PKCS7_free(p7);

return (signature);
}
(NSData*)获取签名
{
无符号字符sha_缓冲区[SHA256_摘要_长度];
memset((void*)sha_缓冲区,0,SHA256_摘要长度);
SHA256_最终版(sha_缓冲区和m_sha_ctx);
PKCS7*p7=PKCS7_new();
PKCS7_集合_类型(p7,NID_PKCS7_签名);
PKCS7_签名者_INFO*p7Si=PKCS7_添加_签名(p7,mp_x509,mp_pkey,EVP_sha256());
PKCS7添加属性内容类型(p7Si,OBJ_nid2obj(NID_PKCS7_数据));
PKCS7添加0属性签名时间(p7Si,空);
PKCS7_add1_attrib_digest(p7Si,(常量无符号字符*)sha_缓冲区,SHA256_digest_长度);
PKCS7_添加_证书(p7,mp_x509);
int c=0;
对于(;c
如何添加我的CSR as属性以获取附加签名?