Great that you got it to work "the proper way".

/hh

Den tors 13 apr. 2023 03:12David Castillo via curl-library <
curl-library@lists.haxx.se> skrev:

> Okay, I think I have a solution that can work for me :) I used the
> https://curl.se/libcurl/c/CURLOPT_SSL_CTX_FUNCTION.html callback and I'm
> reading the der file and adding it to the store, similar to the example in
> the docs. It's something like this:
>
> static CURLcode sslctx_function(CURL *curl, void *sslctx, void *parm) {
>     X509_STORE *store;
>     X509 *cert = NULL;
>     FILE *derCert = fopen("/data/misc/user/0/cacerts-added/924c6f19.0",
> "r");
>
>     // Create cert from file
>     cert = d2i_X509_fp(derCert, NULL);
>     if(cert == NULL)
>         printf("d2i_X509_fp failed...\n");
>
>     /* get a pointer to the X509 certificate store (which may be empty) */
>     store = SSL_CTX_get_cert_store((SSL_CTX *)sslctx);
>
>     /* add our certificate to this store */
>     if(X509_STORE_add_cert(store, cert) == 0)
>         printf("error adding certificate\n");
>
>     /* decrease reference counts */
>     X509_free(cert);
>
>     /* all set to go */
>     return CURLE_OK;
> }
>
> Thanks all for your help!! I'm not sure if the thread needs to be marked
> as solved or anything.
> --
> Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-library
> Etiquette:   https://curl.se/mail/etiquette.html
>
-- 
Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-library
Etiquette:   https://curl.se/mail/etiquette.html

Reply via email to