SSL_CTX_use_PrivateKey_bio(SSL_CTX *ctx, BIO* in, int type,
                           const char *key_passwd)
{
  int ret = 0;
  EVP_PKEY *pkey = NULL;

  if(type == SSL_FILETYPE_PEM)
    pkey = PEM_read_bio_PrivateKey(in, NULL, passwd_callback,
                                   (void *)key_passwd);
  else if(type == SSL_FILETYPE_ASN1)
    pkey = d2i_PrivateKey_bio(in, NULL);
  else {
    ret = 0;
    goto end;
  }
  if(pkey == NULL) {
    ret = 0;
    goto end;
  }
  ret = SSL_CTX_use_PrivateKey(ctx, pkey);
  EVP_PKEY_free(pkey);
  end:
  return ret;
}
SSL_CTX_use_PrivateKey_bio(SSL_CTX *ctx, BIO* in, int type,
                           const char *key_passwd)
{
  int ret = 0;
  EVP_PKEY *pkey = NULL;

  if(type == SSL_FILETYPE_PEM)
    pkey = PEM_read_bio_PrivateKey(in, NULL, passwd_callback,
                                   (void *)key_passwd);
  else if(type == SSL_FILETYPE_ASN1)
    pkey = d2i_PrivateKey_bio(in, NULL);
  else {
    ret = 0;
    goto end;
  }
  if(pkey == NULL) {
    ret = 0;
    goto end;
  }
  ret = SSL_CTX_use_PrivateKey(ctx, pkey);
  EVP_PKEY_free(pkey);
  end:
  return ret;
}