您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ BIO_read_filename函数代码示例

51自学网 2021-06-01 19:50:13
  C++
这篇教程C++ BIO_read_filename函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中BIO_read_filename函数的典型用法代码示例。如果您正苦于以下问题:C++ BIO_read_filename函数的具体用法?C++ BIO_read_filename怎么用?C++ BIO_read_filename使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了BIO_read_filename函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: SSL_use_certificate_file

int SSL_use_certificate_file(SSL *ssl, const char *file, int type) {  int reason_code;  BIO *in;  int ret = 0;  X509 *x = NULL;  in = BIO_new(BIO_s_file());  if (in == NULL) {    OPENSSL_PUT_ERROR(SSL, ERR_R_BUF_LIB);    goto end;  }  if (BIO_read_filename(in, file) <= 0) {    OPENSSL_PUT_ERROR(SSL, ERR_R_SYS_LIB);    goto end;  }  if (type == SSL_FILETYPE_ASN1) {    reason_code = ERR_R_ASN1_LIB;    x = d2i_X509_bio(in, NULL);  } else if (type == SSL_FILETYPE_PEM) {    reason_code = ERR_R_PEM_LIB;    x = PEM_read_bio_X509(in, NULL, ssl->ctx->default_passwd_callback,                          ssl->ctx->default_passwd_callback_userdata);  } else {    OPENSSL_PUT_ERROR(SSL, SSL_R_BAD_SSL_FILETYPE);    goto end;  }  if (x == NULL) {    OPENSSL_PUT_ERROR(SSL, reason_code);    goto end;  }  ret = SSL_use_certificate(ssl, x);end:  X509_free(x);  BIO_free(in);  return ret;}
开发者ID:a397871706,项目名称:plug,代码行数:42,


示例2: SSL_use_certificate_file

int SSL_use_certificate_file(SSL *ssl, const char *file, int type){    int j;    BIO *in;    int ret = 0;    X509 *x = NULL;    in = BIO_new(BIO_s_file_internal());    if (in == NULL) {        SSLerr(SSL_F_SSL_USE_CERTIFICATE_FILE, ERR_R_BUF_LIB);        goto end;    }    if (BIO_read_filename(in, file) <= 0) {        SSLerr(SSL_F_SSL_USE_CERTIFICATE_FILE, ERR_R_SYS_LIB);        goto end;    }    if (type == SSL_FILETYPE_ASN1) {        j = ERR_R_ASN1_LIB;        x = d2i_X509_bio(in, NULL);    } else if (type == SSL_FILETYPE_PEM) {        j = ERR_R_PEM_LIB;        x = PEM_read_bio_X509(in, NULL, ssl->ctx->default_passwd_callback,                              ssl->ctx->default_passwd_callback_userdata);    } else {        SSLerr(SSL_F_SSL_USE_CERTIFICATE_FILE, SSL_R_BAD_SSL_FILETYPE);        goto end;    }    if (x == NULL) {        SSLerr(SSL_F_SSL_USE_CERTIFICATE_FILE, j);        goto end;    }    ret = SSL_use_certificate(ssl, x); end:    if (x != NULL)        X509_free(x);    if (in != NULL)        BIO_free(in);    return (ret);}
开发者ID:johnjohnsp1,项目名称:opensgx,代码行数:42,


示例3: STACK_OF

int SSLContext::setCertificateChainFile( const char * pFile ){    BIO *bio;    X509 *x509;    STACK_OF(X509) * pExtraCerts;    unsigned long err;    int n;    if ((bio = BIO_new(BIO_s_file_internal())) == NULL)        return 0;    if (BIO_read_filename(bio, pFile) <= 0) {        BIO_free(bio);        return 0;    }    pExtraCerts=m_pCtx->extra_certs;    if ( pExtraCerts != NULL)     {        sk_X509_pop_free((STACK_OF(X509) *)pExtraCerts, X509_free);        m_pCtx->extra_certs = NULL;    }
开发者ID:ewwink,项目名称:openlitespeed,代码行数:20,


示例4: LOGGER_FN

Handle<CertificationRequest> Provider_System::getCSRFromURI(Handle<std::string> uri, Handle<std::string> format){	LOGGER_FN();	try{		BIO *bioFile = NULL;		X509_REQ *hreq = NULL;		LOGGER_OPENSSL(BIO_new);		bioFile = BIO_new(BIO_s_file());		LOGGER_OPENSSL(BIO_read_filename);		if (BIO_read_filename(bioFile, uri->c_str()) > 0){			LOGGER_OPENSSL(BIO_seek);			BIO_seek(bioFile, 0);			if (strcmp(format->c_str(), "PEM") == 0){				LOGGER_OPENSSL(PEM_read_bio_X509_REQ);				hreq = PEM_read_bio_X509_REQ(bioFile, NULL, NULL, NULL);			}			else if (strcmp(format->c_str(), "DER") == 0){				LOGGER_OPENSSL(d2i_X509_REQ_bio);				hreq = d2i_X509_REQ_bio(bioFile, NULL);			}			else{				THROW_EXCEPTION(0, Provider_System, NULL, "Unsupported format. Only PEM | DER");			}		}		LOGGER_OPENSSL(BIO_free);		BIO_free(bioFile);		if (!hreq){			THROW_EXCEPTION(0, Provider_System, NULL, "Unable decode csr from PEM/DER");		}		else{			return new CertificationRequest(hreq);		}	}	catch (Handle<Exception> e){		THROW_EXCEPTION(0, Provider_System, e, "getCSRFromURI");	}}
开发者ID:algv,项目名称:trusted-crypto,代码行数:41,


示例5: SSL_CTX_use_certificate_file

intSSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, int type){	int j;	BIO *in;	int ret = 0;	X509 *x = NULL;	in = BIO_new(BIO_s_file_internal());	if (in == NULL) {		SSLerrorx(ERR_R_BUF_LIB);		goto end;	}	if (BIO_read_filename(in, file) <= 0) {		SSLerrorx(ERR_R_SYS_LIB);		goto end;	}	if (type == SSL_FILETYPE_ASN1) {		j = ERR_R_ASN1_LIB;		x = d2i_X509_bio(in, NULL);	} else if (type == SSL_FILETYPE_PEM) {		j = ERR_R_PEM_LIB;		x = PEM_read_bio_X509(in, NULL, ctx->default_passwd_callback,		    ctx->default_passwd_callback_userdata);	} else {		SSLerrorx(SSL_R_BAD_SSL_FILETYPE);		goto end;	}	if (x == NULL) {		SSLerrorx(j);		goto end;	}	ret = SSL_CTX_use_certificate(ctx, x);end:	X509_free(x);	BIO_free(in);	return (ret);}
开发者ID:libressl-portable,项目名称:openbsd,代码行数:41,


示例6: apr_jwk_parse_rsa_key

static apr_byte_t apr_jwk_parse_rsa_key(apr_pool_t *pool, int is_private_key,		const char *filename, apr_jwk_t **j_jwk, apr_jwt_error_t *err) {	BIO *input = NULL;	apr_jwk_key_rsa_t *key = NULL;	apr_byte_t rv = FALSE;	if ((input = BIO_new(BIO_s_file())) == NULL) {		apr_jwt_error_openssl(err, "BIO_new/BIO_s_file");		goto end;	}	if (BIO_read_filename(input, filename) <= 0) {		apr_jwt_error_openssl(err, "BIO_read_filename");		goto end;	}	if (apr_jwk_rsa_bio_to_key(pool, input, &key, is_private_key, err) == FALSE)		goto end;	/* allocate memory for the JWK */	*j_jwk = apr_pcalloc(pool, sizeof(apr_jwk_t));	apr_jwk_t *jwk = *j_jwk;	jwk->type = APR_JWK_KEY_RSA;	jwk->key.rsa = key;	/* calculate a unique key identifier (kid) by fingerprinting the key params */	// TODO: based just on sha1 hash of modulus "n" now..., could do this based on jwk->value.str	if (apr_jwk_hash_and_base64urlencode(pool, key->modulus, key->modulus_len,			&jwk->kid, err) == FALSE)		goto end;	rv = TRUE;end:	if (input)		BIO_free(input);	return rv;}
开发者ID:justingreerbbi,项目名称:mod_auth_openidc,代码行数:41,


示例7: ERR_print_errors

static SSL_SESSION *load_sess_id(char *infile, int format)	{	SSL_SESSION *x=NULL;	BIO *in=NULL;	in=BIO_new(BIO_s_file());	if (in == NULL)		{		ERR_print_errors(bio_err);		goto end;		}	if (infile == NULL)		BIO_set_fp(in,stdin,BIO_NOCLOSE);	else		{		if (BIO_read_filename(in,infile) <= 0)			{			perror(infile);			goto end;			}		}	if 	(format == FORMAT_ASN1)		x=d2i_SSL_SESSION_bio(in,NULL);	else if (format == FORMAT_PEM)		x=PEM_read_bio_SSL_SESSION(in,NULL,NULL,NULL);	else	{		BIO_printf(bio_err,"bad input format specified for input crl/n");		goto end;		}	if (x == NULL)		{		BIO_printf(bio_err,"unable to load SSL_SESSION/n");		ERR_print_errors(bio_err);		goto end;		}	end:	if (in != NULL) BIO_free(in);	return(x);	}
开发者ID:ahenroid,项目名称:ptptl-0.2,代码行数:41,


示例8: ERR_print_errors

static X509_CRL *load_crl(char *infile, int format)	{	X509_CRL *x=NULL;	BIO *in=NULL;	in=BIO_new(BIO_s_file());	if (in == NULL)		{		ERR_print_errors(bio_err);		goto end;		}	if (infile == NULL)		BIO_set_fp(in,OPENSSL_TYPE__FILE_STDIN,BIO_NOCLOSE);	else		{		if (BIO_read_filename(in,infile) <= 0)			{			TINYCLR_SSL_PERROR(infile);			goto end;			}		}	if 	(format == FORMAT_ASN1)		x=d2i_X509_CRL_bio(in,NULL);	else if (format == FORMAT_PEM)		x=PEM_read_bio_X509_CRL(in,NULL,NULL,NULL);	else	{		BIO_printf(bio_err,"bad input format specified for input crl/n");		goto end;		}	if (x == NULL)		{		BIO_printf(bio_err,"unable to load CRL/n");		ERR_print_errors(bio_err);		goto end;		}	end:	BIO_free(in);	return(x);	}
开发者ID:EddieGarmon,项目名称:netduino-netmf,代码行数:41,


示例9: SSL_use_RSAPrivateKey_file

int SSL_use_RSAPrivateKey_file(SSL *ssl, const char *file, int type) {  int reason_code, ret = 0;  BIO *in;  RSA *rsa = NULL;  in = BIO_new(BIO_s_file());  if (in == NULL) {    OPENSSL_PUT_ERROR(SSL, ERR_R_BUF_LIB);    goto end;  }  if (BIO_read_filename(in, file) <= 0) {    OPENSSL_PUT_ERROR(SSL, ERR_R_SYS_LIB);    goto end;  }  if (type == SSL_FILETYPE_ASN1) {    reason_code = ERR_R_ASN1_LIB;    rsa = d2i_RSAPrivateKey_bio(in, NULL);  } else if (type == SSL_FILETYPE_PEM) {    reason_code = ERR_R_PEM_LIB;    rsa =        PEM_read_bio_RSAPrivateKey(in, NULL, ssl->ctx->default_passwd_callback,                                   ssl->ctx->default_passwd_callback_userdata);  } else {    OPENSSL_PUT_ERROR(SSL, SSL_R_BAD_SSL_FILETYPE);    goto end;  }  if (rsa == NULL) {    OPENSSL_PUT_ERROR(SSL, reason_code);    goto end;  }  ret = SSL_use_RSAPrivateKey(ssl, rsa);  RSA_free(rsa);end:  BIO_free(in);  return ret;}
开发者ID:a397871706,项目名称:plug,代码行数:40,


示例10: SSL_CTX_use_PrivateKey_file

intSSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *file, int type){	int j, ret = 0;	BIO *in;	EVP_PKEY *pkey = NULL;	in = BIO_new(BIO_s_file_internal());	if (in == NULL) {		SSLerr(SSL_F_SSL_CTX_USE_PRIVATEKEY_FILE, ERR_R_BUF_LIB);		goto end;	}	if (BIO_read_filename(in, file) <= 0) {		SSLerr(SSL_F_SSL_CTX_USE_PRIVATEKEY_FILE, ERR_R_SYS_LIB);		goto end;	}	if (type == SSL_FILETYPE_PEM) {		j = ERR_R_PEM_LIB;		pkey = PEM_read_bio_PrivateKey(in, NULL,		    ctx->default_passwd_callback,		    ctx->default_passwd_callback_userdata);	} else if (type == SSL_FILETYPE_ASN1) {		j = ERR_R_ASN1_LIB;		pkey = d2i_PrivateKey_bio(in, NULL);	} else {		SSLerr(SSL_F_SSL_CTX_USE_PRIVATEKEY_FILE,		    SSL_R_BAD_SSL_FILETYPE);		goto end;	}	if (pkey == NULL) {		SSLerr(SSL_F_SSL_CTX_USE_PRIVATEKEY_FILE, j);		goto end;	}	ret = SSL_CTX_use_PrivateKey(ctx, pkey);	EVP_PKEY_free(pkey);end:	BIO_free(in);	return (ret);}
开发者ID:NSGod,项目名称:openbsd,代码行数:40,


示例11: SSL_use_RSAPrivateKey_file

int SSL_use_RSAPrivateKey_file(SSL *ssl, const char *file, int type){    int j, ret = 0;    BIO *in;    RSA *rsa = NULL;    in = BIO_new(BIO_s_file_internal());    if (in == NULL) {        SSLerr(SSL_F_SSL_USE_RSAPRIVATEKEY_FILE, ERR_R_BUF_LIB);        goto end;    }    if (BIO_read_filename(in, file) <= 0) {        SSLerr(SSL_F_SSL_USE_RSAPRIVATEKEY_FILE, ERR_R_SYS_LIB);        goto end;    }    if (type == SSL_FILETYPE_ASN1) {        j = ERR_R_ASN1_LIB;        rsa = d2i_RSAPrivateKey_bio(in, NULL);    } else if (type == SSL_FILETYPE_PEM) {        j = ERR_R_PEM_LIB;        rsa = PEM_read_bio_RSAPrivateKey(in, NULL,                                         ssl->ctx->default_passwd_callback,                                         ssl->                                         ctx->default_passwd_callback_userdata);    } else {        SSLerr(SSL_F_SSL_USE_RSAPRIVATEKEY_FILE, SSL_R_BAD_SSL_FILETYPE);        goto end;    }    if (rsa == NULL) {        SSLerr(SSL_F_SSL_USE_RSAPRIVATEKEY_FILE, j);        goto end;    }    ret = SSL_use_RSAPrivateKey(ssl, rsa);    RSA_free(rsa); end:    if (in != NULL)        BIO_free(in);    return (ret);}
开发者ID:johnjohnsp1,项目名称:opensgx,代码行数:40,


示例12: us894_test16

/* * Null Server certificate when initializing server */static void us894_test16 (void){    unsigned char *cacerts = NULL;    int cacerts_len = 0;    BIO *keyin;    EVP_PKEY *priv_key;    int rv;    EST_CTX *ctx;    LOG_FUNC_NM;        /*     * Read in the CA certificates     */    cacerts_len = read_binary_file(US894_CACERT, &cacerts);    CU_ASSERT(cacerts_len > 0);    /*     * Read the server key      */    keyin = BIO_new(BIO_s_file_internal());    rv = BIO_read_filename(keyin, US894_SERVER_KEY);    CU_ASSERT(rv > 0);    priv_key = PEM_read_bio_PrivateKey(keyin, NULL, NULL, NULL);    CU_ASSERT(priv_key != NULL);    BIO_free(keyin);    /*      * Attempt to init EST proxy using NULL server key     */    est_init_logger(EST_LOG_LVL_INFO, NULL);    ctx = est_proxy_init(cacerts, cacerts_len, cacerts, cacerts_len,                          EST_CERT_FORMAT_PEM,                         "testrealm", NULL, priv_key,                         "estuser", "estpwd");    CU_ASSERT(ctx == NULL);    EVP_PKEY_free(priv_key);}
开发者ID:DDvO,项目名称:libest,代码行数:42,


示例13: SSL_CTX_use_PrivateKey_file

int SSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *file, int type) {  int reason_code, ret = 0;  BIO *in;  EVP_PKEY *pkey = NULL;  in = BIO_new(BIO_s_file());  if (in == NULL) {    OPENSSL_PUT_ERROR(SSL, ERR_R_BUF_LIB);    goto end;  }  if (BIO_read_filename(in, file) <= 0) {    OPENSSL_PUT_ERROR(SSL, ERR_R_SYS_LIB);    goto end;  }  if (type == SSL_FILETYPE_PEM) {    reason_code = ERR_R_PEM_LIB;    pkey = PEM_read_bio_PrivateKey(in, NULL, ctx->default_passwd_callback,                                   ctx->default_passwd_callback_userdata);  } else if (type == SSL_FILETYPE_ASN1) {    reason_code = ERR_R_ASN1_LIB;    pkey = d2i_PrivateKey_bio(in, NULL);  } else {    OPENSSL_PUT_ERROR(SSL, SSL_R_BAD_SSL_FILETYPE);    goto end;  }  if (pkey == NULL) {    OPENSSL_PUT_ERROR(SSL, reason_code);    goto end;  }  ret = SSL_CTX_use_PrivateKey(ctx, pkey);  EVP_PKEY_free(pkey);end:  BIO_free(in);  return ret;}
开发者ID:a397871706,项目名称:plug,代码行数:39,


示例14: read_requestorstuff

/* * read requestor data * * for version 2 requests, the requestor and the SCEP client can be different * and the request does not need to be a PKCS#10 */static int	read_requestorstuff(scep_t *scep, int type, char *filename) {	BIO		*bio;	NETSCAPE_SPKI	*spki = NULL;	X509_REQ	*req = NULL;	bio = BIO_new(BIO_s_file());	if (BIO_read_filename(bio, filename) < 0) {		BIO_printf(bio_err, "%s:%d: cannot read request file '%s'/n",			__FILE__, __LINE__, filename);		goto err;	}	switch (type) {	case 0:		scep->requestorreq = d2i_X509_REQ_bio(bio, &req);		if (scep->requestorreq == NULL) {			BIO_printf(bio_err, "%s:%d: cannot decode X509_REQ/n",				__FILE__, __LINE__);			goto err;		}		scep->requestorpubkey			= X509_REQ_get_pubkey(scep->requestorreq);		break;	case 1:		scep->requestorspki = d2i_NETSCAPE_SPKI_bio(bio, &spki);		if (scep->requestorspki == NULL) {			BIO_printf(bio_err, "%s:%d: cannot decode SPKI/n",				__FILE__, __LINE__);			goto err;		}		scep->requestorpubkey			= NETSCAPE_SPKI_get_pubkey(scep->requestorspki);		break;	default:		goto err;	}	return 0;err:	ERR_print_errors(bio_err);	return -1;}
开发者ID:xman1979,项目名称:openscep,代码行数:45,


示例15: us894_test17

/* * Null Server certificate private key when initializing server */static void us894_test17 (void){    unsigned char *cacerts = NULL;    int cacerts_len = 0;    BIO *certin;    X509 *x;    int rv;    EST_CTX *ctx;    LOG_FUNC_NM;        /*     * Read in the CA certificates     */    cacerts_len = read_binary_file(US894_CACERT, &cacerts);    CU_ASSERT(cacerts_len > 0);    /*     * Read the server cert     */    certin = BIO_new(BIO_s_file_internal());    rv = BIO_read_filename(certin, US894_SERVER_CERT);     CU_ASSERT(rv > 0);    x = PEM_read_bio_X509(certin, NULL, NULL, NULL);    CU_ASSERT(x != NULL);    BIO_free(certin);    /*      * Attempt to init EST proxy using NULL private key     */    est_init_logger(EST_LOG_LVL_INFO, NULL);    ctx = est_proxy_init(cacerts, cacerts_len, cacerts, cacerts_len,                         EST_CERT_FORMAT_PEM,                          "testrealm", x, NULL,                         "estuser", "estpwd");    CU_ASSERT(ctx == NULL);    X509_free(x);}
开发者ID:DDvO,项目名称:libest,代码行数:42,


示例16: tls_ctx_read_certificate_file

/* * Based on SSL_CTX_use_certificate_file, return an x509 object for the * given file. */static inttls_ctx_read_certificate_file(SSL_CTX *ctx, const char *file, X509 **x509){  int j;  BIO *in;  int ret=0;  X509 *x=NULL;  in=BIO_new(BIO_s_file_internal());  if (in == NULL)    {      SSLerr(SSL_F_SSL_CTX_USE_CERTIFICATE_FILE, ERR_R_BUF_LIB);      goto end;    }  if (BIO_read_filename(in,file) <= 0)    {      SSLerr(SSL_F_SSL_CTX_USE_CERTIFICATE_FILE, ERR_R_SYS_LIB);      goto end;    }  x = PEM_read_bio_X509(in, NULL, ctx->default_passwd_callback,    ctx->default_passwd_callback_userdata);  if (x == NULL)    {      SSLerr(SSL_F_SSL_CTX_USE_CERTIFICATE_FILE, ERR_R_PEM_LIB);      goto end;    } end:  if (in != NULL)    BIO_free(in);  if (x509)    *x509 = x;  else if (x)    X509_free (x);  return(ret);}
开发者ID:andj,项目名称:openvpn-ssl-refactoring,代码行数:42,


示例17: SSL_CTX_use_certificate_chain_file

intSSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file){	BIO *in;	int ret = 0;	in = BIO_new(BIO_s_file_internal());	if (in == NULL) {		SSLerr(SSL_F_SSL_CTX_USE_CERTIFICATE_CHAIN_FILE, ERR_R_BUF_LIB);		goto end;	}	if (BIO_read_filename(in, file) <= 0) {		SSLerr(SSL_F_SSL_CTX_USE_CERTIFICATE_CHAIN_FILE, ERR_R_SYS_LIB);		goto end;	}	ret = ssl_ctx_use_certificate_chain_bio(ctx, in);end:	BIO_free(in);	return (ret);}
开发者ID:NSGod,项目名称:openbsd,代码行数:23,


示例18: BIO_new

EVP_PKEY* VSslServer::loadKey(VError& error, QString fileName){  BIO* bio = BIO_new(BIO_s_file());  if (bio == NULL)  {    QString msg = "BIO_s_file return NULL";    LOG_ERROR("%s", qPrintable(msg));    error = VSslError(msg, VSslError::IN_BIO_S_FILE);    return NULL;  }  long res = BIO_read_filename(bio, qPrintable(fileName));  if (res <= 0)  {    QString msg = QString("BIO_read_filename(%1) return %2").arg(fileName).arg(res);    LOG_ERROR("%s", qPrintable(msg));    error = VSslError(msg, VSslError::IN_BIO_READ_FILENAME);    BIO_free(bio);    return NULL;  }  EVP_PKEY* key = PEM_read_bio_PrivateKey(bio, NULL,    NULL, // (pem_password_cb*)password_callback // gilgil temp 2008.10.29    NULL  // &cb_data);  );  if (key == NULL)  {    QString msg = "PEM_read_bio_PrivateKey return NULL";    LOG_ERROR("%s", qPrintable(msg));    error = VSslError(msg, VSslError::IN_PEM_READ_BIO_PRIVATEKEY);    BIO_free(bio);    return NULL;  }  BIO_free(bio);  return key;}
开发者ID:AmesianX,项目名称:vdream,代码行数:37,


示例19: STACK_OF

STACK_OF(X509)* bdoc::X509Cert::loadX509Stack(const std::string& path){	STACK_OF(X509)* stack = sk_X509_new_null();	if (stack == NULL) {		THROW_STACK_EXCEPTION("Failed to create X.509 certificate stack.");	}	BIO* file = BIO_new(BIO_s_file());	BIO_scope fileScope(&file);	if (file == NULL) {		THROW_STACK_EXCEPTION("Failed to open X.509 certificates file '%s': %s",				path.c_str(), ERR_reason_error_string(ERR_get_error()));	}	if (BIO_read_filename(file, path.c_str()) <= 0) {		THROW_STACK_EXCEPTION("Failed to open X.509 certificates file '%s': %s",				path.c_str(), ERR_reason_error_string(ERR_get_error()));	}	STACK_OF(X509_INFO)* certsInfo = PEM_X509_INFO_read_bio(file, NULL, NULL, NULL);	if (certsInfo == NULL) {		THROW_STACK_EXCEPTION("Failed to read X.509 certificates from file '%s': %s",				path.c_str(), ERR_reason_error_string(ERR_get_error()));	}	for (int i = 0; i < sk_X509_INFO_num(certsInfo); i++) {		X509_INFO* xi = sk_X509_INFO_value(certsInfo, i);		if (xi->x509 != NULL) {			sk_X509_push(stack, xi->x509);			xi->x509 = NULL;		}	}	sk_X509_INFO_pop_free(certsInfo, X509_INFO_free);	return stack;}
开发者ID:Augustyn,项目名称:evalimine,代码行数:37,


示例20: apr_jwk_pem_to_json_impl

/* * convert PEM formatted public/private key file to JSON string representation */static apr_byte_t apr_jwk_pem_to_json_impl(apr_pool_t *pool,		const char *filename, char **s_jwk, char**s_kid, int is_private_key) {	BIO *input = NULL;	apr_jwk_key_rsa_t *key = NULL;	apr_byte_t rv = FALSE;	if ((input = BIO_new(BIO_s_file())) == NULL)		goto end;	if (BIO_read_filename(input, filename) <= 0)		goto end;	if (apr_jwk_rsa_bio_to_key(pool, input, &key, is_private_key) == FALSE)		goto end;	rv = apr_jwk_rsa_to_json(pool, key, s_jwk, s_kid);end:	if (input)		BIO_free(input);	return rv;}
开发者ID:Acidburn0zzz,项目名称:mod_auth_openidc,代码行数:27,


示例21: SSL_CTX_use_PrivateKey_file_pass

int SSL_CTX_use_PrivateKey_file_pass (SSL_CTX * ctx, char *filename, char *pass){    EVP_PKEY *pkey = NULL;    BIO *key = NULL;    key = BIO_new (BIO_s_file ());    BIO_read_filename (key, filename);    pkey = PEM_read_bio_PrivateKey (key, NULL, NULL, pass);    if (pkey == NULL)    {        printf ("PEM_read_bio_PrivateKey err");        return -1;    }    if (SSL_CTX_use_PrivateKey (ctx, pkey) <= 0)    {        printf ("SSL_CTX_use_PrivateKey err/n");        return -1;    }    BIO_free (key);    return 1;}
开发者ID:274914765,项目名称:C,代码行数:24,


示例22: BIO_new

void LLBasicCertificateStore::load_from_file(const std::string& filename){	// scan the PEM file extracting each certificate	if (!LLFile::isfile(filename))	{		return;	}		BIO* file_bio = BIO_new(BIO_s_file());	if(file_bio)	{		if (BIO_read_filename(file_bio, filename.c_str()) > 0)		{				X509 *cert_x509 = NULL;			while((PEM_read_bio_X509(file_bio, &cert_x509, 0, NULL)) && 				  (cert_x509 != NULL))			{				try				{					add(new LLBasicCertificate(cert_x509));				}				catch (...)				{					LL_WARNS("SECAPI") << "Failure creating certificate from the certificate store file." << LL_ENDL;				}				X509_free(cert_x509);				cert_x509 = NULL;			}			BIO_free(file_bio);		}	}	else	{		LL_WARNS("SECAPI") << "Could not allocate a file BIO" << LL_ENDL;	}}
开发者ID:OS-Development,项目名称:VW.Zen,代码行数:36,


示例23: XSEC_RELEASE_XMLCH

XSECCryptoKey * InteropResolver::openCertURI(const XMLCh * uri) {	// Open a certificate from a file URI relative to the signature file	BIO * bioCert;	if ((bioCert = BIO_new(BIO_s_file())) == NULL) {				return NULL;	}	safeBuffer fname;	char * u = XMLString::transcode(uri);	fname.sbTranscodeIn(mp_baseURI);	fname.sbStrcatIn("/");	fname.sbStrcatIn(u);	XSEC_RELEASE_XMLCH(u);#if defined(_WIN32)	reverseSlash(fname);#endif	if (BIO_read_filename(bioCert, fname.rawCharBuffer()) <= 0) {				return NULL;	}	X509 * x509 = d2i_X509_bio(bioCert, NULL);	BIO_free(bioCert);	OpenSSLCryptoX509 oX509(x509);	X509_free(x509);	return oX509.clonePublicKey();}
开发者ID:12019,项目名称:svn.gov.pt,代码行数:36,


示例24: MAIN

//.........这里部分代码省略.........#ifndef OPENSSL_NO_IDEA		BIO_printf(bio_err," -idea     - encrypt the generated key with IDEA in cbc mode/n");#endif#ifndef OPENSSL_NO_SEED		BIO_printf(bio_err," -seed/n");		BIO_printf(bio_err,"                 encrypt PEM output with cbc seed/n");#endif#ifndef OPENSSL_NO_AES		BIO_printf(bio_err," -aes128, -aes192, -aes256/n");		BIO_printf(bio_err,"                 encrypt PEM output with cbc aes/n");#endif#ifndef OPENSSL_NO_CAMELLIA		BIO_printf(bio_err," -camellia128, -camellia192, -camellia256/n");		BIO_printf(bio_err,"                 encrypt PEM output with cbc camellia/n");#endif#ifndef OPENSSL_NO_ENGINE		BIO_printf(bio_err," -engine e - use engine e, possibly a hardware device./n");#endif		BIO_printf(bio_err," -rand file%cfile%c.../n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR);		BIO_printf(bio_err,"           - load the file (or the files in the directory) into/n");		BIO_printf(bio_err,"             the random number generator/n");		BIO_printf(bio_err," dsaparam-file/n");		BIO_printf(bio_err,"           - a DSA parameter file as generated by the dsaparam command/n");		goto end;		}#ifndef OPENSSL_NO_ENGINE        e = setup_engine(bio_err, engine, 0);#endif	if(!app_passwd(bio_err, NULL, passargout, NULL, &passout)) {		BIO_printf(bio_err, "Error getting password/n");		goto end;	}	in=BIO_new(BIO_s_file());	if (!(BIO_read_filename(in,dsaparams)))		{		perror(dsaparams);		goto end;		}	if ((dsa=PEM_read_bio_DSAparams(in,NULL,NULL,NULL)) == NULL)		{		BIO_printf(bio_err,"unable to load DSA parameter file/n");		goto end;		}	BIO_free(in);	in = NULL;			out=BIO_new(BIO_s_file());	if (out == NULL) goto end;	if (outfile == NULL)		{		BIO_set_fp(out,stdout,BIO_NOCLOSE);#ifdef OPENSSL_SYS_VMS		{		BIO *tmpbio = BIO_new(BIO_f_linebuffer());		out = BIO_push(tmpbio, out);		}#endif		}	else		{		if (BIO_write_filename(out,outfile) <= 0)			{			perror(outfile);			goto end;			}		}	if (!app_RAND_load_file(NULL, bio_err, 1) && inrand == NULL)		{		BIO_printf(bio_err,"warning, not much extra random data, consider using the -rand option/n");		}	if (inrand != NULL)		BIO_printf(bio_err,"%ld semi-random bytes loaded/n",			app_RAND_load_files(inrand));	BIO_printf(bio_err,"Generating DSA key, %d bits/n",							BN_num_bits(dsa->p));	if (!DSA_generate_key(dsa)) goto end;	app_RAND_write_file(NULL, bio_err);	if (!PEM_write_bio_DSAPrivateKey(out,dsa,enc,NULL,0,NULL, passout))		goto end;	ret=0;end:	if (ret != 0)		ERR_print_errors(bio_err);	if (in != NULL) BIO_free(in);	if (out != NULL) BIO_free_all(out);	if (dsa != NULL) DSA_free(dsa);	if(passout) OPENSSL_free(passout);	apps_shutdown();	OPENSSL_EXIT(ret);	}
开发者ID:LucidOne,项目名称:Rovio,代码行数:101,


示例25: dgst_main

//.........这里部分代码省略.........            goto end;        }        if (sigopts) {            char *sigopt;            for (i = 0; i < sk_OPENSSL_STRING_num(sigopts); i++) {                sigopt = sk_OPENSSL_STRING_value(sigopts, i);                if (pkey_ctrl_string(pctx, sigopt) <= 0) {                    BIO_printf(bio_err, "parameter error /"%s/"/n", sigopt);                    ERR_print_errors(bio_err);                    goto end;                }            }        }    }    /* we use md as a filter, reading from 'in' */    else {        EVP_MD_CTX *mctx = NULL;        if (!BIO_get_md_ctx(bmd, &mctx)) {            BIO_printf(bio_err, "Error getting context/n");            ERR_print_errors(bio_err);            goto end;        }        if (md == NULL)            md = EVP_md5();        if (!EVP_DigestInit_ex(mctx, md, impl)) {            BIO_printf(bio_err, "Error setting digest/n");            ERR_print_errors(bio_err);            goto end;        }    }    if (sigfile && sigkey) {        BIO *sigbio = BIO_new_file(sigfile, "rb");        if (!sigbio) {            BIO_printf(bio_err, "Error opening signature file %s/n", sigfile);            ERR_print_errors(bio_err);            goto end;        }        siglen = EVP_PKEY_size(sigkey);        sigbuf = app_malloc(siglen, "signature buffer");        siglen = BIO_read(sigbio, sigbuf, siglen);        BIO_free(sigbio);        if (siglen <= 0) {            BIO_printf(bio_err, "Error reading signature file %s/n", sigfile);            ERR_print_errors(bio_err);            goto end;        }    }    inp = BIO_push(bmd, in);    if (md == NULL) {        EVP_MD_CTX *tctx;        BIO_get_md_ctx(bmd, &tctx);        md = EVP_MD_CTX_md(tctx);    }    if (argc == 0) {        BIO_set_fp(in, stdin, BIO_NOCLOSE);        ret = do_fp(out, buf, inp, separator, out_bin, sigkey, sigbuf,                    siglen, NULL, NULL, "stdin", bmd);    } else {        const char *md_name = NULL, *sig_name = NULL;        if (!out_bin) {            if (sigkey) {                const EVP_PKEY_ASN1_METHOD *ameth;                ameth = EVP_PKEY_get0_asn1(sigkey);                if (ameth)                    EVP_PKEY_asn1_get0_info(NULL, NULL,                                            NULL, NULL, &sig_name, ameth);            }            if (md)                md_name = EVP_MD_name(md);        }        ret = 0;        for (i = 0; i < argc; i++) {            int r;            if (BIO_read_filename(in, argv[i]) <= 0) {                perror(argv[i]);                ret++;                continue;            } else                r = do_fp(out, buf, inp, separator, out_bin, sigkey, sigbuf,                          siglen, sig_name, md_name, argv[i], bmd);            if (r)                ret = r;            (void)BIO_reset(bmd);        }    } end:    OPENSSL_clear_free(buf, BUFSIZE);    BIO_free(in);    OPENSSL_free(passin);    BIO_free_all(out);    EVP_PKEY_free(sigkey);    sk_OPENSSL_STRING_free(sigopts);    sk_OPENSSL_STRING_free(macopts);    OPENSSL_free(sigbuf);    BIO_free(bmd);    return (ret);}
开发者ID:GH-JY,项目名称:openssl,代码行数:101,


示例26: MAIN

//.........这里部分代码省略.........		BIO_printf(bio_err," -out arg      output file (output format is always DER/n");		BIO_printf(bio_err," -noout arg    don't produce any output/n");		BIO_printf(bio_err," -offset arg   offset into file/n");		BIO_printf(bio_err," -length arg   length of section in file/n");		BIO_printf(bio_err," -i            indent entries/n");		BIO_printf(bio_err," -dump         dump unknown data in hex form/n");		BIO_printf(bio_err," -dlimit arg   dump the first arg bytes of unknown data in hex form/n");		BIO_printf(bio_err," -oid file     file of extra oid definitions/n");		BIO_printf(bio_err," -strparse offset/n");		BIO_printf(bio_err,"               a series of these can be used to 'dig' into multiple/n");		BIO_printf(bio_err,"               ASN1 blob wrappings/n");		goto end;		}	ERR_load_crypto_strings();	in=BIO_new(BIO_s_file());	out=BIO_new(BIO_s_file());	if ((in == NULL) || (out == NULL))		{		ERR_print_errors(bio_err);		goto end;		}	BIO_set_fp(out,stdout,BIO_NOCLOSE|BIO_FP_TEXT);#ifdef VMS	{	BIO *tmpbio = BIO_new(BIO_f_linebuffer());	out = BIO_push(tmpbio, out);	}#endif	if (oidfile != NULL)		{		if (BIO_read_filename(in,oidfile) <= 0)			{			BIO_printf(bio_err,"problems opening %s/n",oidfile);			ERR_print_errors(bio_err);			goto end;			}		OBJ_create_objects(in);		}	if (infile == NULL)		BIO_set_fp(in,stdin,BIO_NOCLOSE);	else		{		if (BIO_read_filename(in,infile) <= 0)			{			perror(infile);			goto end;			}		}	if (derfile) {		if(!(derout = BIO_new_file(derfile, "wb"))) {			BIO_printf(bio_err,"problems opening %s/n",derfile);			ERR_print_errors(bio_err);			goto end;		}	}	if ((buf=BUF_MEM_new()) == NULL) goto end;	if (!BUF_MEM_grow(buf,BUFSIZ*8)) goto end; /* Pre-allocate :-) */	if (informat == FORMAT_PEM)		{
开发者ID:aosm,项目名称:OpenSSL096,代码行数:67,


示例27: MAIN

//.........这里部分代码省略.........		X509V3_set_nconf(&ctx2, extconf);		if (!X509V3_EXT_add_nconf(extconf, &ctx2, extsect, NULL))			{			BIO_printf(bio_err,				"Error Loading extension section %s/n",								 extsect);			ERR_print_errors(bio_err);			goto end;			}		}	if (reqfile)		{		EVP_PKEY *pkey;		BIO *in;		if (!sign_flag && !CA_flag)			{			BIO_printf(bio_err,"We need a private key to sign with/n");			goto end;			}		in=BIO_new(BIO_s_file());		if (in == NULL)			{			ERR_print_errors(bio_err);			goto end;			}		if (infile == NULL)			BIO_set_fp(in,stdin,BIO_NOCLOSE|BIO_FP_TEXT);		else			{			if (BIO_read_filename(in,infile) <= 0)				{				perror(infile);				BIO_free(in);				goto end;				}			}		req=PEM_read_bio_X509_REQ(in,NULL,NULL,NULL);		BIO_free(in);		if (req == NULL)			{			ERR_print_errors(bio_err);			goto end;			}		if (	(req->req_info == NULL) ||			(req->req_info->pubkey == NULL) ||			(req->req_info->pubkey->public_key == NULL) ||			(req->req_info->pubkey->public_key->data == NULL))			{			BIO_printf(bio_err,"The certificate request appears to corrupted/n");			BIO_printf(bio_err,"It does not contain a public key/n");			goto end;			}		if ((pkey=X509_REQ_get_pubkey(req)) == NULL)	                {	                BIO_printf(bio_err,"error unpacking public key/n");	                goto end;	                }		i=X509_REQ_verify(req,pkey);		EVP_PKEY_free(pkey);		if (i < 0)
开发者ID:0omega,项目名称:platform_external_openssl,代码行数:67,



注:本文中的BIO_read_filename函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ BIO_reset函数代码示例
C++ BIO_read函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。