使用libCurl为EST客户端注册simplereenroll

使用libCurl为EST客户端注册simplereenroll,c,linux,security,curl,libcurl,C,Linux,Security,Curl,Libcurl,我正在尝试使用libcurl在C中开发一个EST客户端程序,以执行SimplenRoll和simplereenroll。到目前为止,我能够使用/well-known/est/simpleenroll.检索证书,但我在执行/well-known/est/simpleenroll时遇到问题 url = self.url_prefix + '/simplereenroll' auth = (self.username, self.password) headers =

我正在尝试使用libcurl在C中开发一个EST客户端程序,以执行SimplenRoll和simplereenroll。到目前为止,我能够使用/well-known/est/simpleenroll.检索证书,但我在执行/well-known/est/simpleenroll时遇到问题

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);