本文整理汇总了C++中ERR_error_string_n函数的典型用法代码示例。如果您正苦于以下问题:C++ ERR_error_string_n函数的具体用法?C++ ERR_error_string_n怎么用?C++ ERR_error_string_n使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ERR_error_string_n函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ssl_readable
int ssl_readable(struct worker_t *self, struct client_t *c)
{
int r;
int sslerr, err;
//hlog(LOG_DEBUG, "ssl_readable fd %d", c->fd);
ssl_clear_error();
r = SSL_read(c->ssl_con->connection, c->ibuf + c->ibuf_end, c->ibuf_size - c->ibuf_end - 1);
if (r > 0) {
/* we got some data... process */
//hlog(LOG_DEBUG, "SSL_read fd %d returned %d bytes of data", c->fd, r);
/* TODO: whatever the client_readable does */
return client_postread(self, c, r);
}
sslerr = SSL_get_error(c->ssl_con->connection, r);
err = (sslerr == SSL_ERROR_SYSCALL) ? errno : 0;
if (sslerr == SSL_ERROR_WANT_READ) {
hlog(LOG_DEBUG, "ssl_readable fd %d: SSL_read wants to read again, doing it later", c->fd);
if (c->obuf_end - c->obuf_start > 0) {
/* tell the poller that we have outgoing data */
xpoll_outgoing(&self->xp, c->xfd, 1);
}
return 0;
}
if (sslerr == SSL_ERROR_WANT_WRITE) {
hlog(LOG_INFO, "ssl_readable fd %d: SSL_read wants to write (peer starts SSL renegotiation?), calling ssl_write", c->fd);
return ssl_write(self, c);
}
c->ssl_con->no_wait_shutdown = 1;
c->ssl_con->no_send_shutdown = 1;
if (sslerr == SSL_ERROR_ZERO_RETURN || ERR_peek_error() == 0) {
hlog(LOG_DEBUG, "ssl_readable fd %d: peer shutdown SSL cleanly", c->fd);
client_close(self, c, CLIERR_EOF);
return -1;
}
if (err) {
hlog(LOG_DEBUG, "ssl_readable fd %d: I/O syscall error: %s", c->fd, strerror(err));
} else {
char ebuf[255];
ERR_error_string_n(sslerr, ebuf, sizeof(ebuf));
hlog(LOG_INFO, "ssl_readable fd %d failed with ret %d sslerr %d errno %d: %s (%s)",
c->fd, r, sslerr, err, ebuf, ERR_reason_error_string(sslerr));
}
client_close(self, c, err);
return -1;
}
示例2: disable_ssl
static void disable_ssl(int do_errors)
{
if(do_errors)
{
char buf[256];
unsigned long e;
while((e = ERR_get_error()))
{
ERR_error_string_n(e, buf, sizeof(buf) - 1);
Debug((DEBUG_DEBUG, "%s", buf));
if (serverbooting) {
(void)fprintf(stderr, "%s\n", buf);
}
}
}
if (sslable) {
if ((bootopt & BOOT_TTY) && (bootopt & BOOT_DEBUG))
(void)fprintf(stderr, "disable_ssl(): EVP_cleanup()\n");
EVP_cleanup();
}
if(ctx) {
if ((bootopt & BOOT_TTY) && (bootopt & BOOT_DEBUG))
(void)fprintf(stderr, "disable_ssl(): SSL_CTX_free()\n");
SSL_CTX_free(ctx);
}
Debug((DEBUG_DEBUG, "SSL support is disabled."));
sslable = 0;
return;
}
示例3: dst__openssl_toresult3
isc_result_t
dst__openssl_toresult3(isc_logcategory_t *category,
const char *funcname, isc_result_t fallback) {
isc_result_t result;
unsigned long err;
const char *file, *data;
int line, flags;
char buf[256];
result = toresult(fallback);
isc_log_write(dns_lctx, category,
DNS_LOGMODULE_CRYPTO, ISC_LOG_WARNING,
"%s failed (%s)", funcname,
isc_result_totext(result));
if (result == ISC_R_NOMEMORY)
goto done;
for (;;) {
err = ERR_get_error_line_data(&file, &line, &data, &flags);
if (err == 0U)
goto done;
ERR_error_string_n(err, buf, sizeof(buf));
isc_log_write(dns_lctx, category,
DNS_LOGMODULE_CRYPTO, ISC_LOG_INFO,
"%s:%s:%d:%s", buf, file, line,
(flags & ERR_TXT_STRING) ? data : "");
}
done:
ERR_clear_error();
return (result);
}
示例4: SSL_get_error
Boolean SSLSocket::incompleteSecureReadOccurred(Sint32 retCode)
{
Sint32 err = SSL_get_error(static_cast<SSL*>(_SSLConnection), retCode);
Boolean isIncompleteRead =
((err == SSL_ERROR_SYSCALL) &&
(_sslReadErrno == EAGAIN || _sslReadErrno == EINTR)) ||
(err == SSL_ERROR_WANT_READ) ||
(err == SSL_ERROR_WANT_WRITE);
if (Tracer::isTraceOn())
{
unsigned long rc = ERR_get_error ();
char buff[256];
ERR_error_string_n (rc, buff, sizeof (buff)); // added in OpenSSL 0.9.6
PEG_TRACE((TRC_SSL, Tracer::LEVEL4,
"In SSLSocket::incompleteSecureReadOccurred : err = %d %s",
err, buff));
if (!isIncompleteRead && retCode < 0)
{
PEG_TRACE((TRC_DISCARDED_DATA, Tracer::LEVEL4,
"In SSLSocket::incompleteSecureReadOccurred : err = %d %s",
err, buff));
}
}
return isIncompleteRead;
}
示例5: msn_ssl_new
MsnSsl *
msn_ssl_new (void)
{
MsnSsl *ssl;
ssl = g_new0 (MsnSsl, 1);
ssl->ctx = SSL_CTX_new (SSLv23_client_method ());
if (ssl->ctx == NULL)
{
char errmsg[128] = {0};
ERR_error_string_n (ERR_get_error (), errmsg, 128);
g_print ("error: %s\n", errmsg);
msn_ssl_free (ssl);
return NULL;
}
/* turn on all SSL implementation bug workarounds. */
SSL_CTX_set_options (ssl->ctx, SSL_OP_ALL);
/* don't do the verification. */
SSL_CTX_set_verify (ssl->ctx, SSL_VERIFY_NONE, NULL);
ssl->ssl = SSL_new (ssl->ctx);
return ssl;
}
示例6: while
/**
* Serves the entire OpenSSL error queue and logs each error.
* The last error is not logged but returned in 'errstr'.
*
* If 'rkb' is non-NULL broker-specific logging will be used,
* else it will fall back on global 'rk' debugging.
*/
static char *rd_kafka_ssl_error (rd_kafka_t *rk, rd_kafka_broker_t *rkb,
char *errstr, size_t errstr_size) {
unsigned long l;
const char *file, *data;
int line, flags;
int cnt = 0;
while ((l = ERR_get_error_line_data(&file, &line, &data, &flags)) != 0) {
char buf[256];
if (cnt++ > 0) {
/* Log last message */
if (rkb)
rd_rkb_log(rkb, LOG_ERR, "SSL", "%s", errstr);
else
rd_kafka_log(rk, LOG_ERR, "SSL", "%s", errstr);
}
ERR_error_string_n(l, buf, sizeof(buf));
rd_snprintf(errstr, errstr_size, "%s:%d: %s: %s",
file, line, buf, (flags & ERR_TXT_STRING) ? data : "");
}
if (cnt == 0)
rd_snprintf(errstr, errstr_size, "No error");
return errstr;
}
示例7: reportError
void reportError(SSL* ssl, int result)
{
if (result <= 0)
{
int error = SSL_get_error(ssl, result);
switch (error)
{
case SSL_ERROR_ZERO_RETURN:
cout << "SSL_ERROR_ZERO_RETURN" << endl;
break;
case SSL_ERROR_NONE:
cout << "SSL_ERROR_NONE" << endl;
break;
case SSL_ERROR_WANT_READ:
cout << "SSL_ERROR_WANT_READ" << endl;
break;
default:
char buffer[256];
while (error != 0)
{
ERR_error_string_n(error, buffer, sizeof(buffer));
cout << "Error: " << error << " - " << buffer << endl;
error = ERR_get_error();
}
break;
}
}
}
示例8: opensslconnect
static Pfd*
opensslconnect(char *host)
{
Pfd *pfd;
BIO *sbio;
SSL_CTX *ctx;
SSL *ssl;
static int didinit;
char buf[1024];
if(!didinit){
httpsinit();
didinit = 1;
}
ctx = SSL_CTX_new(SSLv23_client_method());
sbio = BIO_new_ssl_connect(ctx);
BIO_get_ssl(sbio, &ssl);
SSL_set_mode(ssl, SSL_MODE_AUTO_RETRY);
snprint(buf, sizeof buf, "%s:https", host);
BIO_set_conn_hostname(sbio, buf);
if(BIO_do_connect(sbio) <= 0 || BIO_do_handshake(sbio) <= 0){
ERR_error_string_n(ERR_get_error(), buf, sizeof buf);
BIO_free_all(sbio);
werrstr("openssl: %s", buf);
return nil;
}
pfd = emalloc(sizeof *pfd);
pfd->sbio = sbio;
return pfd;
}
示例9: 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;
}
示例10: ERR_print_errors_cb
void ERR_print_errors_cb(int (*cb) (const char *str, size_t len, void *u),
void *u)
{
unsigned long l;
char buf[256];
char buf2[4096];
const char *file, *data;
int line, flags;
/*
* We don't know what kind of thing CRYPTO_THREAD_ID is. Here is our best
* attempt to convert it into something we can print.
*/
union {
CRYPTO_THREAD_ID tid;
unsigned long ltid;
} tid;
tid.ltid = 0;
tid.tid = CRYPTO_THREAD_get_current_id();
while ((l = ERR_get_error_line_data(&file, &line, &data, &flags)) != 0) {
ERR_error_string_n(l, buf, sizeof(buf));
BIO_snprintf(buf2, sizeof(buf2), "%lu:%s:%s:%d:%s\n", tid.ltid, buf,
file, line, (flags & ERR_TXT_STRING) ? data : "");
if (cb(buf2, strlen(buf2), u) <= 0)
break; /* abort outputting the error report */
}
}
示例11: tqsl_getErrorString_v
DLLEXPORT const char *
tqsl_getErrorString_v(int err) {
static char buf[256];
unsigned long openssl_err;
int adjusted_err;
if (err == 0)
return "NO ERROR";
if (err == TQSL_CUSTOM_ERROR) {
if (tQSL_CustomError[0] == 0)
return "Unknown custom error";
else {
strncpy(buf, tQSL_CustomError, sizeof buf);
return buf;
}
}
if (err == TQSL_SYSTEM_ERROR) {
strcpy(buf, "System error: ");
if (strlen(tQSL_ErrorFile) > 0) {
strncat(buf, tQSL_ErrorFile, sizeof buf - strlen(buf));
strncat(buf, ": ", sizeof buf - strlen(buf));
}
strncat(buf, strerror(errno), sizeof buf - strlen(buf));
return buf;
}
if (err == TQSL_OPENSSL_ERROR) {
openssl_err = ERR_get_error();
strcpy(buf, "OpenSSL error: ");
if (openssl_err)
ERR_error_string_n(openssl_err, buf + strlen(buf), sizeof buf - strlen(buf));
else
strncat(buf, "[error code not available]", sizeof buf - strlen(buf));
return buf;
}
if (err == TQSL_ADIF_ERROR) {
buf[0] = 0;
if (strlen(tQSL_ErrorFile) > 0) {
strncpy(buf, tQSL_ErrorFile, sizeof buf);
strncat(buf, ": ", sizeof buf - strlen(buf));
}
strncat(buf, tqsl_adifGetError(tQSL_ADIF_Error), sizeof buf - strlen(buf));
return buf;
}
if (err == TQSL_CABRILLO_ERROR) {
buf[0] = 0;
if (strlen(tQSL_ErrorFile) > 0) {
strncpy(buf, tQSL_ErrorFile, sizeof buf);
strncat(buf, ": ", sizeof buf - strlen(buf));
}
strncat(buf, tqsl_cabrilloGetError(tQSL_Cabrillo_Error), sizeof buf - strlen(buf));
return buf;
}
if (err == TQSL_OPENSSL_VERSION_ERROR) {
sprintf(buf, "Incompatible OpenSSL Library version %d.%d.%d; expected %d.%d.%d",
int(SSLeay() >> 28) & 0xff, int(SSLeay() >> 20) & 0xff, int(SSLeay() >> 12) & 0xff,
int(OPENSSL_VERSION_NUMBER >> 28) & 0xff, int(OPENSSL_VERSION_NUMBER >> 20) & 0xff,
int(OPENSSL_VERSION_NUMBER >> 12) & 0xff);
return buf;
}
示例12: openssl_errormsg
char*
openssl_errormsg(char *buf, size_t len) {
ERR_error_string_n(ERR_get_error(), buf, len);
/* clear rest of errors in OpenSSL "error buffer" */
ERR_clear_error();
return(buf);
}
示例13: ssl_error
static const char *
ssl_error(void)
{
/* Minimum requirement is 120 characters */
static char ssl_errbuf[256];
ERR_error_string_n(ERR_get_error(), ssl_errbuf, sizeof(ssl_errbuf));
return ssl_errbuf;
}
示例14: get_ssl_error
static const char *
get_ssl_error(unsigned long err)
{
static char buf[512];
ERR_error_string_n(err, buf, sizeof buf);
return buf;
}
示例15: LogSSLErrors
// This dumps the SSL error stack to the log.
static void LogSSLErrors(const std::string& prefix) {
char error_buf[200];
unsigned long err;
while ((err = ERR_get_error())) {
ERR_error_string_n(err, error_buf, sizeof(error_buf));
LOG(LS_ERROR) << prefix << ": " << error_buf << "\n";
}
}