Advertisement
splash5

Load cert from memory

Nov 26th, 2017
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.60 KB | None | 0 0
  1. static CURLcode SSLCTX_Callback(CURL *curl, void *ssl_ctx, void *user)
  2. {
  3.     X509_STORE *store;
  4.     X509 *cert = NULL;
  5.     BIO *bio;
  6.  
  7.     STACK_OF(X509_INFO) *inf;
  8.     X509_INFO *itmp;
  9.     int i;
  10.  
  11.     store = SSL_CTX_get_cert_store((SSL_CTX *)ssl_ctx);
  12.     bio = BIO_new_mem_buf(MY_ACCEPTED_PEM, -1);
  13.     inf = PEM_X509_INFO_read_bio(bio, NULL, NULL, "");
  14.     BIO_free(bio);
  15.  
  16.     if (inf)
  17.     {
  18.         for (i = 0; i < sk_X509_INFO_num(inf); i++)
  19.         {
  20.             itmp = sk_X509_INFO_value(inf, i);
  21.             if (itmp->x509)
  22.                 X509_STORE_add_cert(store, itmp->x509);
  23.         }
  24.     }
  25.  
  26.     sk_X509_INFO_pop_free(inf, X509_INFO_free);
  27.  
  28.     return CURLE_OK;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement