本文整理汇总了C++中ERR_GET_LIB函数的典型用法代码示例。如果您正苦于以下问题:C++ ERR_GET_LIB函数的具体用法?C++ ERR_GET_LIB怎么用?C++ ERR_GET_LIB使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ERR_GET_LIB函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
const char *ERR_reason_error_string(unsigned long e)
{
ERR_STRING_DATA d,*p=NULL;
unsigned long l,r;
l=ERR_GET_LIB(e);
r=ERR_GET_REASON(e);
CRYPTO_r_lock(CRYPTO_LOCK_ERR_HASH);
if (error_hash != NULL)
{
d.error=ERR_PACK(l,0,r);
p=(ERR_STRING_DATA *)lh_retrieve(error_hash,&d);
if (p == NULL)
{
d.error=ERR_PACK(0,0,r);
p=(ERR_STRING_DATA *)lh_retrieve(error_hash,&d);
}
}
CRYPTO_r_unlock(CRYPTO_LOCK_ERR_HASH);
return((p == NULL)?NULL:p->string);
}
示例2: iotssl_log_errors
void
iotssl_log_errors(lcbio_XSSL *xs)
{
unsigned long curerr;
while ((curerr = ERR_get_error())) {
char errbuf[4096];
ERR_error_string_n(curerr, errbuf, sizeof errbuf);
lcb_log(LOGARGS(xs->ssl, LCB_LOG_ERROR), "%s", errbuf);
if (xs->errcode != LCB_SUCCESS) {
continue; /* Already set */
}
if (ERR_GET_LIB(curerr) == ERR_LIB_SSL) {
switch (ERR_GET_REASON(curerr)) {
case SSL_R_CERTIFICATE_VERIFY_FAILED:
case SSL_R_MISSING_VERIFY_MESSAGE:
xs->errcode = LCB_SSL_CANTVERIFY;
break;
case SSL_R_BAD_PROTOCOL_VERSION_NUMBER:
case SSL_R_UNKNOWN_PROTOCOL:
case SSL_R_WRONG_VERSION_NUMBER:
case SSL_R_UNKNOWN_SSL_VERSION:
case SSL_R_UNSUPPORTED_SSL_VERSION:
xs->errcode = LCB_PROTOCOL_ERROR;
break;
default:
xs->errcode = LCB_SSL_ERROR;
}
}
}
}
示例3: toresult
static isc_result_t
toresult(isc_result_t fallback) {
isc_result_t result = fallback;
unsigned long err = ERR_get_error();
#ifdef HAVE_OPENSSL_ECDSA
int lib = ERR_GET_LIB(err);
#endif
int reason = ERR_GET_REASON(err);
switch (reason) {
/*
* ERR_* errors are globally unique; others
* are unique per sublibrary
*/
case ERR_R_MALLOC_FAILURE:
result = ISC_R_NOMEMORY;
break;
default:
#ifdef HAVE_OPENSSL_ECDSA
if (lib == ERR_R_ECDSA_LIB &&
reason == ECDSA_R_RANDOM_NUMBER_GENERATION_FAILED) {
result = ISC_R_NOENTROPY;
break;
}
#endif
break;
}
return (result);
}
示例4: z_ssl_get_error_str
/**
* Fetch OpenSSL error code and generate a string interpretation of it.
*
* @param[out] buf buffer to put string into
* @param[in] buflen size of buffer
*
* @returns buf
**/
gchar *
z_ssl_get_error_str(gchar *buf, int buflen)
{
const char *ls, *fs, *rs;
unsigned long e, l, f, r;
unsigned long new_error = 0;
gint count = -1;
do {
e = new_error;
new_error= ERR_get_error();
++count;
} while (new_error);
l = ERR_GET_LIB(e);
f = ERR_GET_FUNC(e);
r = ERR_GET_REASON(e);
ls = ERR_lib_error_string(e);
fs = ERR_func_error_string(e);
rs = ERR_reason_error_string(e);
if (count)
g_snprintf(buf, buflen, "error:%08lX:%s:lib(%lu):%s:func(%lu):%s:reason(%lu), supressed %d messages", e, ls ? ls : "(null)", l, fs ? fs : "(null)", f, rs ? rs : "(null)", r, count);
else
g_snprintf(buf, buflen, "error:%08lX:%s:lib(%lu):%s:func(%lu):%s:reason(%lu)", e, ls ? ls : "(null)", l, fs ? fs : "(null)", f, rs ? rs : "(null)", r);
return buf;
}
示例5: err_hash
/* static unsigned long err_hash(ERR_STRING_DATA *a) */
static unsigned long err_hash(const void *a_void)
{
unsigned long ret,l;
l=((const ERR_STRING_DATA *)a_void)->error;
ret=l^ERR_GET_LIB(l)^ERR_GET_FUNC(l);
return(ret^ret%19*13);
}
示例6: err_string_data_hash
static unsigned long err_string_data_hash(const ERR_STRING_DATA *a)
{
unsigned long ret, l;
l = a->error;
ret = l ^ ERR_GET_LIB(l) ^ ERR_GET_FUNC(l);
return (ret ^ ret % 19 * 13);
}
示例7: SSL_CTX_use_certificate_chain_mem
int
SSL_CTX_use_certificate_chain_mem(SSL_CTX *ctx, void *data, int data_len)
{
pem_password_cb *psw_fn = ctx->default_passwd_callback;
void *psw_arg = ctx->default_passwd_callback_userdata;
X509 *cert;
BIO *bio = NULL;
int ok;
ERR_clear_error();
/* Read from memory */
bio = BIO_new_mem_buf(data, data_len);
if (!bio) {
SSLerr(SSL_F_SSL_CTX_USE_CERTIFICATE_CHAIN_FILE, ERR_R_BUF_LIB);
goto failed;
}
/* Load primary cert */
cert = PEM_read_bio_X509_AUX(bio, NULL, psw_fn, psw_arg);
if (!cert) {
SSLerr(SSL_F_SSL_CTX_USE_CERTIFICATE_CHAIN_FILE, ERR_R_PEM_LIB);
goto failed;
}
/* Increments refcount */
ok = SSL_CTX_use_certificate(ctx, cert);
X509_free(cert);
if (!ok || ERR_peek_error())
goto failed;
/* Load extra certs */
ok = SSL_CTX_clear_extra_chain_certs(ctx);
while (ok) {
cert = PEM_read_bio_X509(bio, NULL, psw_fn, psw_arg);
if (!cert) {
/* Is it EOF? */
unsigned long err = ERR_peek_last_error();
if (ERR_GET_LIB(err) != ERR_LIB_PEM)
break;
if (ERR_GET_REASON(err) != PEM_R_NO_START_LINE)
break;
/* On EOF do successful exit */
BIO_free(bio);
ERR_clear_error();
return 1;
}
/* Does not increment refcount */
ok = SSL_CTX_add_extra_chain_cert(ctx, cert);
if (!ok)
X509_free(cert);
}
failed:
if (bio)
BIO_free(bio);
return 0;
}
示例8: ERR_peek_error
const char *openssl_iostream_key_load_error(void)
{
unsigned long err = ERR_peek_error();
if (ERR_GET_LIB(err) == ERR_LIB_X509 &&
ERR_GET_REASON(err) == X509_R_KEY_VALUES_MISMATCH)
return "Key is for a different cert than ssl_cert";
else
return openssl_iostream_error();
}
示例9: err_component_error_string
const char *ERR_reason_error_string(uint32_t packed_error) {
const char *reason_str = err_component_error_string(
ERR_PACK(ERR_GET_LIB(packed_error), 0, ERR_GET_REASON(packed_error)));
if (reason_str != NULL) {
return reason_str;
}
return err_component_error_string(
ERR_PACK(0, 0, ERR_GET_REASON(packed_error)));
}
示例10: err_fns_check
const char *ERR_lib_error_string(unsigned long e)
{
ERR_STRING_DATA d,*p;
unsigned long l;
err_fns_check();
l=ERR_GET_LIB(e);
d.error=ERR_PACK(l,0,0);
p=ERRFN(err_get_item)(&d);
return((p == NULL)?NULL:p->string);
}
示例11: checkX509_STORE_error
static int checkX509_STORE_error(char* err, size_t err_len) {
unsigned long errCode = ERR_peek_last_error();
if (ERR_GET_LIB(errCode) != ERR_LIB_X509 ||
ERR_GET_REASON(errCode) != X509_R_CERT_ALREADY_IN_HASH_TABLE) {
snprintf(err,
err_len,
"Error adding certificate to X509 store: %s",
ERR_reason_error_string(errCode));
return 0;
}
return 1;
}
示例12: CRYPTO_THREAD_run_once
const char *ERR_lib_error_string(unsigned long e)
{
ERR_STRING_DATA d, *p;
unsigned long l;
CRYPTO_THREAD_run_once(&err_string_init, do_err_strings_init);
l = ERR_GET_LIB(e);
d.error = ERR_PACK(l, 0, 0);
p = int_err_get_item(&d);
return ((p == NULL) ? NULL : p->string);
}
示例13: ERR_error_string_n
void ERR_error_string_n(unsigned long e, char *buf, size_t len)
{
char lsbuf[64], fsbuf[64], rsbuf[64];
const char *ls, *fs, *rs;
unsigned long l, f, r;
if (len == 0)
return;
l = ERR_GET_LIB(e);
f = ERR_GET_FUNC(e);
r = ERR_GET_REASON(e);
ls = ERR_lib_error_string(e);
fs = ERR_func_error_string(e);
rs = ERR_reason_error_string(e);
if (ls == NULL)
BIO_snprintf(lsbuf, sizeof(lsbuf), "lib(%lu)", l);
if (fs == NULL)
BIO_snprintf(fsbuf, sizeof(fsbuf), "func(%lu)", f);
if (rs == NULL)
BIO_snprintf(rsbuf, sizeof(rsbuf), "reason(%lu)", r);
BIO_snprintf(buf, len, "error:%08lX:%s:%s:%s", e, ls ? ls : lsbuf,
fs ? fs : fsbuf, rs ? rs : rsbuf);
if (strlen(buf) == len - 1) {
/*
* output may be truncated; make sure we always have 5
* colon-separated fields, i.e. 4 colons ...
*/
#define NUM_COLONS 4
if (len > NUM_COLONS) { /* ... if possible */
int i;
char *s = buf;
for (i = 0; i < NUM_COLONS; i++) {
char *colon = strchr(s, ':');
if (colon == NULL || colon > &buf[len - 1] - NUM_COLONS + i) {
/*
* set colon no. i at last possible position (buf[len-1]
* is the terminating 0)
*/
colon = &buf[len - 1] - NUM_COLONS + i;
*colon = ':';
}
s = colon + 1;
}
}
}
}
示例14: ssl_path_err
/** exit with ssl error related to a file path */
static void ssl_path_err(const char* s, const char *path)
{
unsigned long err;
err = ERR_peek_error();
if (ERR_GET_LIB(err) == ERR_LIB_SYS &&
(ERR_GET_FUNC(err) == SYS_F_FOPEN ||
ERR_GET_FUNC(err) == SYS_F_FREAD) ) {
fprintf(stderr, "error: %s\n%s: %s\n",
s, path, ERR_reason_error_string(err));
exit(1);
} else {
ssl_err(s);
}
}
示例15: ERR_GET_LIB
const char *ERR_lib_error_string(unsigned long e)
{
ERR_STRING_DATA d, *p;
unsigned long l;
if (!RUN_ONCE(&err_string_init, do_err_strings_init)) {
return NULL;
}
l = ERR_GET_LIB(e);
d.error = ERR_PACK(l, 0, 0);
p = int_err_get_item(&d);
return ((p == NULL) ? NULL : p->string);
}