src/lib/crypto.c
int crypto_keypair_load_key(X509_KEYPAIR *keypair, const char *file,
                             CRYPTO_PEM_PASSWD_CB *pem_callback,
                             const void *pem_userdata)
{
   BIO *bio;
   PEM_CB_CONTEXT ctx;

   /* Open the file */
   if (!(bio = BIO_new_file(file, "r"))) {
      openssl_post_errors(M_ERROR, _("Unable to open private key file"));
      return false;
   }

   /* Set up PEM encryption callback */
   if (pem_callback) {
      ctx.pem_callback = pem_callback;
      ctx.pem_userdata = pem_userdata;
   } else {
      ctx.pem_callback = crypto_default_pem_callback;
      ctx.pem_userdata = NULL;
   }

   keypair->privkey = PEM_read_bio_PrivateKey(bio, NULL, crypto_pem_callback_dispatch, &ctx);
   BIO_free(bio);
   if (!keypair->privkey) {
      openssl_post_errors(M_ERROR, _("Unable to read private key from file"));
      return false;
   }

   return true;
}
/*
 * Load a PEM-encoded private key.
 *  Returns: true on success
 *           false on failure
 */
Load a PEM-encoded private key.
Returns: true on success
false on failure
Load a PEM - encoded private key . Returns : true on success false on failure
int crypto_keypair_load_key(X509_KEYPAIR *keypair, const char *file,
                             CRYPTO_PEM_PASSWD_CB *pem_callback,
                             const void *pem_userdata)
{
   BIO *bio;
   PEM_CB_CONTEXT ctx;
   if (!(bio = BIO_new_file(file, "r"))) {
      openssl_post_errors(M_ERROR, _("Unable to open private key file"));
      return false;
   }
   if (pem_callback) {
      ctx.pem_callback = pem_callback;
      ctx.pem_userdata = pem_userdata;
   } else {
      ctx.pem_callback = crypto_default_pem_callback;
      ctx.pem_userdata = NULL;
   }
   keypair->privkey = PEM_read_bio_PrivateKey(bio, NULL, crypto_pem_callback_dispatch, &ctx);
   BIO_free(bio);
   if (!keypair->privkey) {
      openssl_post_errors(M_ERROR, _("Unable to read private key from file"));
      return false;
   }
   return true;
}
int crypto_keypair_load_key ( X509_KEYPAIR * keypair , const char * file , CRYPTO_PEM_PASSWD_CB * pem_callback , const void * pem_userdata ) { BIO * bio ; PEM_CB_CONTEXT ctx ; if ( ! ( bio = BIO_new_file ( file , " " ) ) ) { openssl_post_errors ( M_ERROR , _ ( " " ) ) ; return false ; } if ( pem_callback ) { ctx . pem_callback = pem_callback ; ctx . pem_userdata = pem_userdata ; } else { ctx . pem_callback = crypto_default_pem_callback ; ctx . pem_userdata = NULL ; } keypair -> privkey = PEM_read_bio_PrivateKey ( bio , NULL , crypto_pem_callback_dispatch , & ctx ) ; BIO_free ( bio ) ; if ( ! keypair -> privkey ) { openssl_post_errors ( M_ERROR , _ ( " " ) ) ; return false ; } return true ; }
Load a PEM-encoded private key.
Load a PEM - encoded private key .
/* Open the file */ /* Set up PEM encryption callback */