本文整理匯總了C++中ERR_lib_error_string函數的典型用法代碼示例。如果您正苦於以下問題:C++ ERR_lib_error_string函數的具體用法?C++ ERR_lib_error_string怎麽用?C++ ERR_lib_error_string使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了ERR_lib_error_string函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: ssl_init
/* init_ssl()
*
* inputs - nothing
* output - nothing
* side effects - setups SSL context.
*/
static void
ssl_init(void)
{
#ifdef HAVE_LIBCRYPTO
SSL_load_error_strings();
SSLeay_add_ssl_algorithms();
if (!(ConfigServerInfo.server_ctx = SSL_CTX_new(SSLv23_server_method())))
{
const char *s = ERR_lib_error_string(ERR_get_error());
fprintf(stderr, "ERROR: Could not initialize the SSL Server context -- %s\n", s);
ilog(LOG_TYPE_IRCD, "ERROR: Could not initialize the SSL Server context -- %s", s);
exit(EXIT_FAILURE);
return; /* Not reached */
}
SSL_CTX_set_options(ConfigServerInfo.server_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TICKET);
SSL_CTX_set_options(ConfigServerInfo.server_ctx, SSL_OP_SINGLE_DH_USE|SSL_OP_CIPHER_SERVER_PREFERENCE);
SSL_CTX_set_verify(ConfigServerInfo.server_ctx, SSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE,
always_accept_verify_cb);
SSL_CTX_set_session_cache_mode(ConfigServerInfo.server_ctx, SSL_SESS_CACHE_OFF);
SSL_CTX_set_cipher_list(ConfigServerInfo.server_ctx, "EECDH+HIGH:EDH+HIGH:HIGH:!aNULL");
#if OPENSSL_VERSION_NUMBER >= 0x009080FFL && !defined(OPENSSL_NO_ECDH)
{
EC_KEY *key = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
if (key)
{
SSL_CTX_set_tmp_ecdh(ConfigServerInfo.server_ctx, key);
EC_KEY_free(key);
}
}
SSL_CTX_set_options(ConfigServerInfo.server_ctx, SSL_OP_SINGLE_ECDH_USE);
#endif
if (!(ConfigServerInfo.client_ctx = SSL_CTX_new(SSLv23_client_method())))
{
const char *s = ERR_lib_error_string(ERR_get_error());
fprintf(stderr, "ERROR: Could not initialize the SSL Client context -- %s\n", s);
ilog(LOG_TYPE_IRCD, "ERROR: Could not initialize the SSL Client context -- %s", s);
exit(EXIT_FAILURE);
return; /* Not reached */
}
SSL_CTX_set_options(ConfigServerInfo.client_ctx, SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TICKET);
SSL_CTX_set_options(ConfigServerInfo.client_ctx, SSL_OP_SINGLE_DH_USE);
SSL_CTX_set_verify(ConfigServerInfo.client_ctx, SSL_VERIFY_PEER|SSL_VERIFY_CLIENT_ONCE,
always_accept_verify_cb);
SSL_CTX_set_session_cache_mode(ConfigServerInfo.client_ctx, SSL_SESS_CACHE_OFF);
#endif /* HAVE_LIBCRYPTO */
}
示例2: decode_user_key
u2fs_rc decode_user_key(const unsigned char *data, u2fs_EC_KEY_t ** key)
{
if (key == NULL)
return U2FS_MEMORY_ERROR;
EC_GROUP *ecg = EC_GROUP_new_by_curve_name(NID_X9_62_prime256v1);
*key = (u2fs_EC_KEY_t *) EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
EC_POINT *point = EC_POINT_new(ecg);
point_conversion_form_t pcf = POINT_CONVERSION_UNCOMPRESSED;
EC_GROUP_set_point_conversion_form(ecg, pcf);
if (EC_POINT_oct2point(ecg, point, data, U2FS_PUBLIC_KEY_LEN, NULL) == 0) {
if (debug) {
unsigned long err = 0;
err = ERR_get_error();
fprintf(stderr, "Error: %s, %s, %s\n",
ERR_lib_error_string(err),
ERR_func_error_string(err), ERR_reason_error_string(err));
}
*key = NULL;
EC_GROUP_free(ecg);
ecg = NULL;
EC_POINT_free(point);
point = NULL;
return U2FS_CRYPTO_ERROR;
}
EC_GROUP_free(ecg);
ecg = NULL;
if (EC_KEY_set_public_key((EC_KEY *) * key, point) == 0) {
if (debug) {
unsigned long err = 0;
err = ERR_get_error();
fprintf(stderr, "Error: %s, %s, %s\n",
ERR_lib_error_string(err),
ERR_func_error_string(err), ERR_reason_error_string(err));
}
*key = NULL;
EC_POINT_free(point);
point = NULL;
return U2FS_CRYPTO_ERROR;
}
EC_POINT_free(point);
point = NULL;
return U2FS_OK;
}
示例3: openssl_error
int openssl_error(neo4j_logger_t *logger, uint_fast8_t level,
const char *file, unsigned int line)
{
unsigned long code = ERR_get_error();
if (code == 0)
{
neo4j_log_error(logger, "OpenSSL error not available (%s:%d)",
file, line);
return NEO4J_UNEXPECTED_ERROR;
}
if (ERR_get_error() != 0)
{
neo4j_log_error(logger, "OpenSSL error stack too deep (%s:%d)",
file, line);
return NEO4J_UNEXPECTED_ERROR;
}
char ebuf[256];
ERR_error_string_n(code, ebuf, sizeof(ebuf));
neo4j_log(logger, level, "OpenSSL error: %lu:%s:%s:%s", code,
ERR_lib_error_string(code),
ERR_func_error_string(code),
ERR_reason_error_string(code));
return NEO4J_UNEXPECTED_ERROR;
}
示例4: verify_ECDSA
u2fs_rc verify_ECDSA(const unsigned char *dgst, int dgst_len,
const u2fs_ECDSA_t * sig, u2fs_EC_KEY_t * eckey)
{
if (dgst == NULL || dgst_len == 0 || sig == NULL || eckey == NULL)
return U2FS_MEMORY_ERROR;
int rc =
ECDSA_do_verify(dgst, dgst_len, (ECDSA_SIG *) sig, (EC_KEY *) eckey);
if (rc != 1) {
if (rc == -1) {
if (debug) {
unsigned long err = 0;
err = ERR_get_error();
fprintf(stderr, "Error: %s, %s, %s\n",
ERR_lib_error_string(err),
ERR_func_error_string(err), ERR_reason_error_string(err));
}
return U2FS_CRYPTO_ERROR;
} else {
return U2FS_SIGNATURE_ERROR;
}
}
return U2FS_OK;
}
示例5: _mine_set_ssl_error
void _mine_set_ssl_error(MINE *self) {
self->err = 0;
self->errstr = ERR_lib_error_string( ERR_get_error() );
if (self->errstr == NULL) {
self->errstr = "All ok";
}
}
示例6: decode_ECDSA
u2fs_rc decode_ECDSA(const unsigned char *data, size_t len,
u2fs_ECDSA_t ** sig)
{
const unsigned char *p;
if (data == NULL || len == 0 || sig == NULL)
return U2FS_MEMORY_ERROR;
p = data;
*sig = (u2fs_ECDSA_t *) d2i_ECDSA_SIG(NULL, &p, len);
if (*sig == NULL) {
if (debug) {
unsigned long err = 0;
err = ERR_get_error();
fprintf(stderr, "Error: %s, %s, %s\n",
ERR_lib_error_string(err),
ERR_func_error_string(err), ERR_reason_error_string(err));
}
return U2FS_CRYPTO_ERROR;
}
return U2FS_OK;
}
示例7: 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;
}
示例8: decode_X509
u2fs_rc decode_X509(const unsigned char *data, size_t len,
u2fs_X509_t ** cert)
{
const unsigned char *p;
if (data == NULL || len == 0 || cert == NULL)
return U2FS_MEMORY_ERROR;
p = data;
//Always set 1st param to NULL as per http://www.tedunangst.com/flak/post/analysis-of-d2i-X509-reuse
*cert = (u2fs_X509_t *) d2i_X509(NULL, &p, len);
if (*cert == NULL) {
if (debug) {
unsigned long err = 0;
err = ERR_get_error();
fprintf(stderr, "Error: %s, %s, %s\n",
ERR_lib_error_string(err),
ERR_func_error_string(err), ERR_reason_error_string(err));
}
return U2FS_CRYPTO_ERROR;
}
return U2FS_OK;
}
示例9: _setException
/* LCOV_EXCL_START */
static PyObject *
_setException(PyObject *exc)
{
unsigned long errcode;
const char *lib, *func, *reason;
errcode = ERR_peek_last_error();
if (!errcode) {
PyErr_SetString(exc, "unknown reasons");
return NULL;
}
ERR_clear_error();
lib = ERR_lib_error_string(errcode);
func = ERR_func_error_string(errcode);
reason = ERR_reason_error_string(errcode);
if (lib && func) {
PyErr_Format(exc, "[%s: %s] %s", lib, func, reason);
}
else if (lib) {
PyErr_Format(exc, "[%s] %s", lib, reason);
}
else {
PyErr_SetString(exc, reason);
}
return NULL;
}
示例10: setClassName
SSLGeneric::SSLGeneric(){
#ifdef USE_EMBEDDED_CLASSNAMES
setClassName((char *)__xvr2_Net_SSLGeneric);
#endif
//description = (char *)_desc_SSLGeneric;
description = (char *)ERR_lib_error_string(ERR_get_error());
}
示例11: LUA_FUNCTION
static LUA_FUNCTION(openssl_error_string)
{
unsigned long val;
int clear, ret = 0;
if (lua_isnumber(L, 1))
{
val = (unsigned long)lua_tonumber(L, 1);
clear = lua_toboolean(L, 2);
} else
{
val = ERR_get_error();
clear = lua_toboolean(L, 1);
}
if (val)
{
lua_pushinteger(L, val);
lua_pushstring (L, ERR_reason_error_string(val));
lua_pushstring (L, ERR_lib_error_string (val));
lua_pushstring (L, ERR_func_error_string (val));
#ifdef ERR_FATAL_ERROR
lua_pushboolean(L, ERR_FATAL_ERROR (val));
ret = 5;
#else
ret = 4;
#endif
}
if (clear)
ERR_clear_error();
return ret;
}
示例12: extract_EC_KEY_from_X509
u2fs_rc extract_EC_KEY_from_X509(const u2fs_X509_t * cert,
u2fs_EC_KEY_t ** key)
{
if (cert == NULL || key == NULL)
return U2FS_MEMORY_ERROR;
EVP_PKEY *pkey = X509_get_pubkey((X509 *) cert);
if (pkey == NULL) {
if (debug) {
unsigned long err = 0;
err = ERR_get_error();
fprintf(stderr, "Error: %s, %s, %s\n",
ERR_lib_error_string(err),
ERR_func_error_string(err), ERR_reason_error_string(err));
}
return U2FS_CRYPTO_ERROR;
}
*key = (u2fs_EC_KEY_t *) EVP_PKEY_get1_EC_KEY(pkey);
EVP_PKEY_free(pkey);
pkey = NULL;
if (*key == NULL) {
if (debug) {
unsigned long err = 0;
err = ERR_get_error();
fprintf(stderr, "Error: %s, %s, %s\n",
ERR_lib_error_string(err),
ERR_func_error_string(err), ERR_reason_error_string(err));
}
return U2FS_CRYPTO_ERROR;
}
EC_GROUP *ecg = EC_GROUP_new_by_curve_name(NID_X9_62_prime256v1);
EC_KEY_set_asn1_flag((EC_KEY *) * key, OPENSSL_EC_NAMED_CURVE);
EC_KEY_set_group((EC_KEY *) * key, ecg);
EC_GROUP_free(ecg);
ecg = NULL;
return U2FS_OK;
}
示例13: ssl_print_error_queue
static void
ssl_print_error_queue(const char *msg)
{
unsigned long sslcode = ERR_get_error();
do {
yell("--- %s: SSL error: %s:%s:%s",
msg,
ERR_lib_error_string(sslcode),
ERR_func_error_string(sslcode),
ERR_reason_error_string(sslcode));
Debug(DB_SSL, "%s: SSL error: %s:%s:%s",
msg,
ERR_lib_error_string(sslcode),
ERR_func_error_string(sslcode),
ERR_reason_error_string(sslcode));
} while ((sslcode = ERR_get_error()));
}
示例14: print_err
static void
print_err(int val)
{
int err;
while ((err = ERR_get_error())) {
const char *msg = (const char*)ERR_reason_error_string(err);
const char *lib = (const char*)ERR_lib_error_string(err);
const char *func = (const char*)ERR_func_error_string(err);
}
}
示例15: log_transport_tls_read_method
static gssize
log_transport_tls_read_method(LogTransport *s, gpointer buf, gsize buflen, LogTransportAuxData *aux)
{
LogTransportTLS *self = (LogTransportTLS *) s;
gint ssl_error;
gint rc;
/* assume that we need to poll our input for reading unless
* SSL_ERROR_WANT_WRITE is specified by libssl */
self->super.cond = G_IO_IN;
do
{
rc = SSL_read(self->tls_session->ssl, buf, buflen);
if (rc < 0)
{
ssl_error = SSL_get_error(self->tls_session->ssl, rc);
switch (ssl_error)
{
case SSL_ERROR_WANT_READ:
errno = EAGAIN;
break;
case SSL_ERROR_WANT_WRITE:
/* although we are writing this fd, libssl wants to write. This
* happens during renegotiation for example */
self->super.cond = G_IO_OUT;
errno = EAGAIN;
break;
case SSL_ERROR_SYSCALL:
/* errno is set accordingly */
break;
default:
goto tls_error;
}
}
}
while (rc == -1 && errno == EINTR);
return rc;
tls_error:
ssl_error = ERR_get_error();
msg_error("SSL error while reading stream",
evt_tag_printf("tls_error", "%s:%s:%s", ERR_lib_error_string(ssl_error), ERR_func_error_string(ssl_error), ERR_reason_error_string(ssl_error)),
NULL);
ERR_clear_error();
errno = ECONNRESET;
return -1;
}