本文整理汇总了C++中ERR_lib_error_string函数的典型用法代码示例。如果您正苦于以下问题:C++ ERR_lib_error_string函数的具体用法?C++ ERR_lib_error_string怎么用?C++ ERR_lib_error_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ERR_lib_error_string函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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 */
}
开发者ID:codemstr,项目名称:eircd-hybrid-8,代码行数:61,代码来源:ircd.c
示例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;
}
开发者ID:Yubico,项目名称:libu2f-server-dpkg,代码行数:52,代码来源:openssl.c
示例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;
}
开发者ID:Dan-McG,项目名称:libneo4j-client,代码行数:27,代码来源:openssl.c
示例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;
}
开发者ID:Yubico,项目名称:libu2f-server-dpkg,代码行数:26,代码来源:openssl.c
示例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";
}
}
开发者ID:olegwtf,项目名称:mine,代码行数:7,代码来源:mine.c
示例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;
}
开发者ID:Yubico,项目名称:libu2f-server-dpkg,代码行数:26,代码来源:openssl.c
示例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;
}
开发者ID:VPetyaa,项目名称:libzorpll,代码行数:36,代码来源:ssl.c
示例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;
}
开发者ID:Yubico,项目名称:libu2f-server-dpkg,代码行数:26,代码来源:openssl.c
示例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;
}
开发者ID:3lnc,项目名称:cpython,代码行数:29,代码来源:_hashopenssl.c
示例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());
}
开发者ID:coredumped,项目名称:X-VR2,代码行数:7,代码来源:NetworkExceptions.cpp
示例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;
}
开发者ID:mbartosch,项目名称:lua-openssl,代码行数:33,代码来源:openssl.c
示例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;
}
开发者ID:Yubico,项目名称:libu2f-server-dpkg,代码行数:45,代码来源:openssl.c
示例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()));
}
开发者ID:choppsv1,项目名称:ircii,代码行数:18,代码来源:ssl.c
示例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);
}
}
开发者ID:plusxutianyou,项目名称:Libevent,代码行数:10,代码来源:bufferevent_openssl.c
示例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;
}
开发者ID:algernon,项目名称:syslog-ng-old,代码行数:52,代码来源:transport-tls.c
示例16: 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;
}
}
}
}
开发者ID:winstard,项目名称:GmSSL,代码行数:51,代码来源:err.c
示例17: print_err
static void
print_err(int val)
{
int err;
printf("Error was %d\n", val);
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);
printf("%s in %s %s\n", msg, lib, func);
}
}
开发者ID:CTSRD-CHERI,项目名称:cheribsd,代码行数:14,代码来源:bufferevent_openssl.c
示例18: event_error_handler
static void
event_error_handler(struct bufferevent *bev, short what, void *ctx)
{
struct bufferevent *partner = NULL;
ssh_session_t *session = ctx;
if(session == NULL || session->owner_ptr == NULL) {
trace_err("ERROR: .....................");
} else {
partner= session->owner_ptr;
}
if (what & (BEV_EVENT_EOF|BEV_EVENT_ERROR)) {
if (what & BEV_EVENT_ERROR) {
unsigned long err;
while ((err = (bufferevent_get_openssl_error(bev)))) {
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);
fprintf(stderr, "%s in %s %s\n", msg, lib, func);
}
if (errno) {
trace_err("connection error");
}
}
if (partner) {
/* Flush all pending data */
data_read_handler(bev, ctx);
if (evbuffer_get_length(bufferevent_get_output(partner))) {
/* We still have to flush data from the other
* side, but when that's done, close the other
* side.
*/
bufferevent_setcb(partner,
NULL, close_on_finished_writecb,
event_error_handler, NULL);
bufferevent_disable(partner, EV_READ);
} else {
/* We have nothing left to say to the other
* side; close it.
*/
bufferevent_free(partner);
ssh_log(session, "\"%s:closed\"", SESSION_TYPE(session));
}
}
bufferevent_free(bev);
}
}
开发者ID:caidongyun,项目名称:ssh-proxy,代码行数:48,代码来源:ssh-proxy.c
示例19: parcSelfSignedCertificate_CreateRSACertificate
bool
parcSelfSignedCertificate_CreateRSACertificate(const char *subjectname, unsigned keylength, unsigned validityDays, X509 *cert, RSA *rsa, EVP_PKEY *private_key)
{
int res;
bool return_value = false;
BIGNUM *pub_exp;
pub_exp = BN_new();
BN_set_word(pub_exp, RSA_F4);
res = 1;
if (RSA_generate_key_ex(rsa, keylength, pub_exp, NULL)) {
if (EVP_PKEY_set1_RSA(private_key, rsa)) {
if (X509_set_version(cert, 2)) { // 2 => X509v3
return_value = true;
}
}
}
if (return_value) {
// add serial number
if (_addRandomSerial(cert) == true) {
if (_addValidityPeriod(cert, validityDays) == true) {
if (X509_set_pubkey(cert, private_key) == 1) {
if (_addSubjectName(cert, subjectname) == true) {
if (_addExtensions(cert) == true) {
if (_addKeyIdentifier(cert) == true) {
// The certificate is complete, sign it.
if (X509_sign(cert, private_key, EVP_sha256())) {
return_value = true;
} else {
printf("error: (%d) %s\n", res, ERR_lib_error_string(res));
}
}
}
}
}
}
}
}
ERR_print_errors_fp(stdout);
BN_free(pub_exp);
return return_value;
}
开发者ID:isolis,项目名称:Libparc,代码行数:46,代码来源:parc_SelfSignedCertificate.c
示例20: eventcb
static void
eventcb(struct bufferevent *bev, short what, void *ctx)
{
struct bufferevent *partner = ctx;
if (what & (BEV_EVENT_EOF|BEV_EVENT_ERROR)) {
if (what & BEV_EVENT_ERROR) {
unsigned long err;
while ((err = (bufferevent_get_openssl_error(bev)))) {
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);
fprintf(stderr,
"%s in %s %s\n", msg, lib, func);
}
if (errno)
perror("connection error");
}
if (partner) {
/* Flush all pending data */
readcb(bev, ctx);
if (evbuffer_get_length(
bufferevent_get_output(partner))) {
/* We still have to flush data from the other
* side, but when that's done, close the other
* side. */
bufferevent_setcb(partner,
NULL, close_on_finished_writecb,
eventcb, NULL);
bufferevent_disable(partner, EV_READ);
} else {
/* We have nothing left to say to the other
* side; close it. */
bufferevent_free(partner);
}
}
bufferevent_free(bev);
}
}
开发者ID:sambuc,项目名称:netbsd,代码行数:44,代码来源:le-proxy.c
注:本文中的ERR_lib_error_string函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论