微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用libCurl的EST客户端的simplereenroll

如何解决使用libCurl的EST客户端的simplereenroll

我正在尝试使用libcurl在C语​​言中开发EST客户端程序,以执行simpleenroll和simplereenroll。到目前为止,我已经能够使用 .// kNown / est / simpleenroll。来检索证书,但是执行 ./众所周知/ est / simplereenroll时遇到了问题

url = self.url_prefix + '/simplereenroll'
        auth = (self.username,self.password)
        headers = {'Content-Type': 'application/pkcs10'}
        content = est.request.post(url,csr,auth=auth,headers=headers,verify=self.implicit_trust_anchor_cert_path,cert=cert)
        pem = self.pkcs7_to_pem(content)

我正在引用此python代码在这里我可以看到正在通过的证书进行simplereenroll操作。我不知道如何使用libcurl来实现相同的功能

下面提到的是我用来执行simpleenroll的libcurl代码的一部分。

/*SIMPLEENROLL
 *
 */

if (res = curl_easy_setopt(curl,CURLOPT_URL,"https://localhost:4443/.well-kNown/est/simpleenroll")!=CURLE_OK)
    {
        fprintf(stderr,"curl_easy_setopt() Failed: %s\n",curl_easy_strerror(res));
        return 1;
    }
    struct curl_slist* slist = NULL;
    slist = curl_slist_append(slist,"Content-Type: application/pkcs10");
    curl_easy_setopt(curl,CURLOPT_USERPWD,"estuser:estpwd")
    curl_easy_setopt(curl,CURLOPT_HTTPHEADER,slist);
    curl_easy_setopt(curl,CURLOPT_POSTFIELDS,CSR); 
    curl_easy_setopt(curl,CURLOPT_POSTFIELDSIZE,CSR_LEN); 
    if((res = curl_easy_perform(curl))!=CURLE_OK)
    {
        fprintf(stderr,"curl_easy_perform() Failed: %s\n",curl_easy_strerror(res));
        return 1;       
    }

以上代码将从服务器返回客户端证书。现在,我需要在需要提供此证书的地方执行simplereenroll。

解决方法

curl_easy_setopt(curl,CURLOPT_SSLKEY,client_key);
curl_easy_setopt(curl,CURLOPT_SSLCERT,client_cert);
curl_easy_setopt(curl,CURLOPT_CERTINFO,1L);

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。