本文整理汇总了C++中BIO_set_fd函数的典型用法代码示例。如果您正苦于以下问题:C++ BIO_set_fd函数的具体用法?C++ BIO_set_fd怎么用?C++ BIO_set_fd使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了BIO_set_fd函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: transport_attach
BOOL transport_attach(rdpTransport* transport, int sockfd)
{
BIO* socketBio = NULL;
BIO* bufferedBio;
socketBio = BIO_new(BIO_s_simple_socket());
if (!socketBio)
goto fail;
BIO_set_fd(socketBio, sockfd, BIO_CLOSE);
bufferedBio = BIO_new(BIO_s_buffered_socket());
if (!bufferedBio)
goto fail;
bufferedBio = BIO_push(bufferedBio, socketBio);
transport->frontBio = bufferedBio;
return TRUE;
fail:
if (socketBio)
BIO_free_all(socketBio);
else
close(sockfd);
return FALSE;
}
开发者ID:ilammy,项目名称:FreeRDP,代码行数:27,代码来源:transport.c
示例2: my_SSL_set_fd
/* This should exactly match OpenSSL's SSL_set_fd except for using my BIO */
static int
my_SSL_set_fd(Port *port, int fd)
{
int ret = 0;
BIO *bio;
BIO_METHOD *bio_method;
bio_method = my_BIO_s_socket();
if (bio_method == NULL)
{
SSLerr(SSL_F_SSL_SET_FD, ERR_R_BUF_LIB);
goto err;
}
bio = BIO_new(bio_method);
if (bio == NULL)
{
SSLerr(SSL_F_SSL_SET_FD, ERR_R_BUF_LIB);
goto err;
}
BIO_set_data(bio, port);
BIO_set_fd(bio, fd, BIO_NOCLOSE);
SSL_set_bio(port->ssl, bio, bio);
ret = 1;
err:
return ret;
}
开发者ID:adityavs,项目名称:postgres,代码行数:29,代码来源:be-secure-openssl.c
示例3: SSL_free
status_t
BSecureSocket::_SetupCommon(const char* host)
{
// Do this only after BSocket::Connect has checked wether we're already
// connected. We don't want to kill an existing SSL session, as that would
// likely crash the protocol loop for it.
if (fPrivate->fSSL != NULL) {
SSL_free(fPrivate->fSSL);
}
fPrivate->fSSL = SSL_new(BSecureSocket::Private::Context());
if (fPrivate->fSSL == NULL) {
BSocket::Disconnect();
return B_NO_MEMORY;
}
BIO_set_fd(fPrivate->fBIO, fSocket, BIO_NOCLOSE);
SSL_set_bio(fPrivate->fSSL, fPrivate->fBIO, fPrivate->fBIO);
SSL_set_ex_data(fPrivate->fSSL, Private::sDataIndex, this);
if (host != NULL) {
BString hostString = host;
if (hostString != "")
SSL_set_tlsext_host_name(fPrivate->fSSL, host);
}
return B_OK;
}
开发者ID:looncraz,项目名称:haiku,代码行数:28,代码来源:SecureSocket.cpp
示例4: BIO_set_fd
BIO *BIO_new_fd(int fd,int close_flag)
{
BIO *ret;
ret=BIO_new(BIO_s_fd());
if (ret == NULL) return(NULL);
BIO_set_fd(ret,fd,close_flag);
return(ret);
}
开发者ID:002301,项目名称:node,代码行数:8,代码来源:bss_fd.c
示例5: BIO_new
BIO *BIO_new_fd(int fd, int close_flag) {
BIO *ret = BIO_new(BIO_s_fd());
if (ret == NULL) {
return NULL;
}
BIO_set_fd(ret, fd, close_flag);
return ret;
}
开发者ID:RobinWuDev,项目名称:Qt,代码行数:8,代码来源:fd.c
示例6: BIO_set_fd
void OpenSSLUtils::setBioFd(BIO* b, int fd, int flags) {
#ifdef _WIN32
SOCKET sock = portability::sockets::fd_to_socket(fd);
#else
int sock = fd;
#endif
BIO_set_fd(b, sock, flags);
}
开发者ID:GYGit,项目名称:folly,代码行数:8,代码来源:OpenSSLUtils.cpp
示例7: BIO_set_fd
EXPORT_C BIO *BIO_new_dgram(int fd, int close_flag)
{
BIO *ret;
ret=BIO_new(BIO_s_datagram());
if (ret == NULL) return(NULL);
BIO_set_fd(ret,fd,close_flag);
return(ret);
}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:9,代码来源:bss_dgram.c
示例8: rdg_tls_out_connect
BOOL rdg_tls_out_connect(rdpRdg* rdg, const char* hostname, UINT16 port, int timeout)
{
int sockfd = 0;
int status = 0;
BIO* socketBio = NULL;
BIO* bufferedBio = NULL;
rdpSettings* settings = rdg->settings;
assert(hostname != NULL);
sockfd = freerdp_tcp_connect(rdg->context, settings, settings->GatewayHostname,
settings->GatewayPort, timeout);
if (sockfd < 1)
{
return FALSE;
}
socketBio = BIO_new(BIO_s_simple_socket());
if (!socketBio)
{
closesocket(sockfd);
return FALSE;
}
BIO_set_fd(socketBio, sockfd, BIO_CLOSE);
bufferedBio = BIO_new(BIO_s_buffered_socket());
if (!bufferedBio)
{
BIO_free(socketBio);
return FALSE;
}
bufferedBio = BIO_push(bufferedBio, socketBio);
status = BIO_set_nonblock(bufferedBio, TRUE);
if (!status)
{
BIO_free_all(bufferedBio);
return FALSE;
}
rdg->tlsOut->hostname = settings->GatewayHostname;
rdg->tlsOut->port = settings->GatewayPort;
rdg->tlsOut->isGatewayTransport = TRUE;
status = tls_connect(rdg->tlsOut, bufferedBio);
if (status < 1)
{
return FALSE;
}
return TRUE;
}
开发者ID:BrianChangchien,项目名称:FiWoRDC,代码行数:56,代码来源:rdg.c
示例9: int
X509 *SSL_read_X509(FILE *fp, X509 **x509, int (*cb)(char *, int, int, void*))
#endif
{
X509 *rc;
BIO *bioS;
BIO *bioF;
/* 1. try PEM (= DER+Base64+headers) */
#if SSL_LIBRARY_VERSION < 0x00904000
rc = PEM_read_X509(fp, x509, cb);
#else
rc = PEM_read_X509(fp, x509, cb, NULL);
#endif
if (rc == NULL) {
/* 2. try DER+Base64 */
fseek(fp, 0L, SEEK_SET);
if ((bioS = BIO_new(BIO_s_fd())) == NULL)
return NULL;
BIO_set_fd(bioS, fileno(fp), BIO_NOCLOSE);
if ((bioF = BIO_new(BIO_f_base64())) == NULL) {
BIO_free(bioS);
return NULL;
}
bioS = BIO_push(bioF, bioS);
rc = d2i_X509_bio(bioS, NULL);
BIO_free_all(bioS);
if (rc == NULL) {
/* 3. try plain DER */
fseek(fp, 0L, SEEK_SET);
if ((bioS = BIO_new(BIO_s_fd())) == NULL)
return NULL;
BIO_set_fd(bioS, fileno(fp), BIO_NOCLOSE);
rc = d2i_X509_bio(bioS, NULL);
BIO_free(bioS);
}
}
if (rc != NULL && x509 != NULL) {
if (*x509 != NULL)
X509_free(*x509);
*x509 = rc;
}
return rc;
}
开发者ID:AzerTyQsdF,项目名称:osx,代码行数:43,代码来源:ssl_util_ssl.c
示例10: BIO_new
BIO *BIO_new_socket(int fd, int close_flag)
{
BIO *ret;
ret = BIO_new(BIO_s_socket());
if (ret == NULL)
return NULL;
BIO_set_fd(ret, fd, close_flag);
return ret;
}
开发者ID:RTEMS,项目名称:rtems-libbsd,代码行数:10,代码来源:bss_sock.c
示例11: uh_tls_client_ctx_setup
static int uh_tls_client_ctx_setup(SSL *ssl, int socket)
{
BIO *b;
if (!(b = BIO_new(&uh_openssl_bio_methods)))
return 0;
BIO_set_fd(b, socket, BIO_NOCLOSE);
SSL_set_bio(ssl, b, b);
return 1;
}
开发者ID:Cribstone,项目名称:linino,代码行数:12,代码来源:uhttpd-tls.c
示例12: fprintf
BIO *BIO_new_tou_socket(int fd, int close_flag)
{
BIO *ret;
#ifdef DEBUG_TOU_BIO
fprintf(stderr, "BIO_new_tou_socket(%d)\n", fd);
#endif
ret=BIO_new(BIO_s_tou_socket());
if (ret == NULL) return(NULL);
BIO_set_fd(ret,fd,close_flag);
return(ret);
}
开发者ID:MrKID,项目名称:RetroShare,代码行数:12,代码来源:bss_tou.c
示例13: SSL_set_fd_bsd
static int SSL_set_fd_bsd(SSL *s, int fd)
{
int result= -1;
BIO_METHOD *BIO_s_bsdsocket();
BIO *bio;
if ((bio= BIO_new(BIO_s_bsdsocket())))
{
result= BIO_set_fd(bio, fd, BIO_NOCLOSE);
SSL_set_bio(s, bio, bio);
}
return result;
}
开发者ID:1024wow,项目名称:TrinityCore,代码行数:13,代码来源:viossl.c
示例14: poco_assert
void SecureSocketImpl::connectSSL(bool performHandshake)
{
poco_assert (!_pSSL);
poco_assert (_pSocket->initialized());
BIO* pBIO = BIO_new(BIO_s_socket());
if (!pBIO) throw SSLException("Cannot create SSL BIO object");
BIO_set_fd(pBIO, static_cast<int>(_pSocket->sockfd()), BIO_NOCLOSE);
_pSSL = SSL_new(_pContext->sslContext());
if (!_pSSL)
{
BIO_free(pBIO);
throw SSLException("Cannot create SSL object");
}
SSL_set_bio(_pSSL, pBIO, pBIO);
#if OPENSSL_VERSION_NUMBER >= 0x0908060L && !defined(OPENSSL_NO_TLSEXT)
if (!_peerHostName.empty())
{
SSL_set_tlsext_host_name(_pSSL, _peerHostName.c_str());
}
#endif
if (_pSession)
{
SSL_set_session(_pSSL, _pSession->sslSession());
}
try
{
if (performHandshake && _pSocket->getBlocking())
{
int ret = SSL_connect(_pSSL);
handleError(ret);
verifyPeerCertificate();
}
else
{
SSL_set_connect_state(_pSSL);
_needHandshake = true;
}
}
catch (...)
{
SSL_free(_pSSL);
_pSSL = 0;
throw;
}
}
开发者ID:JerkWisdom,项目名称:zpublic,代码行数:50,代码来源:SecureSocketImpl.cpp
示例15: BIO_set_fd
BIO *BIO_new_fd(int fd,int close_flag)
#endif
{
BIO *ret;
#ifndef BIO_FD
ret=BIO_new(BIO_s_socket());
#else
ret=BIO_new(BIO_s_fd());
#endif
if (ret == NULL) return(NULL);
BIO_set_fd(ret,fd,close_flag);
return(ret);
}
开发者ID:houzhenggang,项目名称:mt7688_mips_ecos,代码行数:14,代码来源:bss_sock.c
示例16: tcp_attach
int tcp_attach(rdpTcp* tcp, int sockfd)
{
tcp->sockfd = sockfd;
SetEventFileDescriptor(tcp->event, tcp->sockfd);
ringbuffer_commit_read_bytes(&tcp->xmitBuffer, ringbuffer_used(&tcp->xmitBuffer));
if (tcp->socketBio)
{
if (BIO_set_fd(tcp->socketBio, sockfd, 1) < 0)
return -1;
}
else
{
tcp->socketBio = BIO_new(BIO_s_simple_socket());
if (!tcp->socketBio)
return -1;
BIO_set_fd(tcp->socketBio, sockfd, BIO_CLOSE);
}
if (!tcp->bufferedBio)
{
tcp->bufferedBio = BIO_new(BIO_s_buffered_socket());
if (!tcp->bufferedBio)
return FALSE;
tcp->bufferedBio->ptr = tcp;
tcp->bufferedBio = BIO_push(tcp->bufferedBio, tcp->socketBio);
}
return 0;
}
开发者ID:Auto-Droid,项目名称:FreeRDP,代码行数:36,代码来源:tcp.c
示例17: ocsp_receive_fd
/* we got a connection to the ocsp responder */
int
ocsp_receive_fd(struct iked *env, struct imsg *imsg)
{
struct iked_ocsp_entry *ioe = NULL;
struct iked_ocsp *ocsp = NULL;
struct iked_socket *sock;
char *path = NULL;
int ret = -1;
log_debug("%s: received socket fd %d", __func__, imsg->fd);
if ((ioe = TAILQ_FIRST(&env->sc_ocsp)) == NULL) {
log_debug("%s: oops, no request for", __func__);
close(imsg->fd);
return (-1);
}
TAILQ_REMOVE(&env->sc_ocsp, ioe, ioe_entry);
ocsp = ioe->ioe_ocsp;
free(ioe);
if ((sock = calloc(1, sizeof(*sock))) == NULL)
fatal("ocsp_receive_fd: calloc sock");
/* note that sock_addr is not set */
sock->sock_fd = imsg->fd;
sock->sock_env = env;
ocsp->ocsp_sock = sock;
/* fetch 'path' and 'fd' from imsg */
if ((path = get_string(imsg->data, IMSG_DATA_SIZE(imsg))) == NULL)
goto done;
BIO_set_fd(ocsp->ocsp_cbio, imsg->fd, BIO_NOCLOSE);
if ((ocsp->ocsp_req_ctx = OCSP_sendreq_new(ocsp->ocsp_cbio,
path, NULL, -1)) == NULL)
goto done;
if (!OCSP_REQ_CTX_set1_req(ocsp->ocsp_req_ctx, ocsp->ocsp_req))
goto done;
event_set(&sock->sock_ev, sock->sock_fd, EV_WRITE, ocsp_callback, ocsp);
event_add(&sock->sock_ev, NULL);
ret = 0;
done:
if (ret == -1)
ocsp_validate_finish(ocsp, 0); /* failed */
free(path);
return (ret);
}
开发者ID:jymigeon,项目名称:openiked,代码行数:49,代码来源:ocsp.c
示例18: LLVMFuzzerTestOneInput
int LLVMFuzzerTestOneInput(const uint8_t* buf, size_t len)
{
if (RAND_reset_for_fuzzing) {
RAND_reset_for_fuzzing();
}
SSL* server = SSL_new(ctx);
BIO* in = BIO_new(BIO_s_mem());
BIO_write(in, buf, len);
BIO* out = BIO_new(BIO_s_fd());
BIO_set_fd(out, 1, BIO_NOCLOSE);
SSL_set_bio(server, in, out);
if (SSL_accept(server) == 1) {
X509* peer;
if ((peer = SSL_get_peer_certificate(server)) != NULL) {
SSL_get_verify_result(server);
X509_free(peer);
}
uint8_t tmp[1024 * 1024];
for (;;) {
ssize_t r = SSL_read(server, tmp, sizeof(tmp));
if (r <= 0) {
SSL_shutdown(server);
break;
}
if (SSL_write(server, tmp, r) <= 0) {
SSL_shutdown(server);
break;
}
#ifndef OPENSSL_NO_HEARTBEATS
SSL_heartbeat(server);
#endif /* ifndef OPENSSL_NO_HEARTBEATS */
}
} else {
ERR_print_errors_fp(stderr);
}
SSL_free(server);
return 0;
}
开发者ID:chubbymaggie,项目名称:honggfuzz,代码行数:45,代码来源:server.c
示例19: connection_exception
connection::connection(int socketin,SSL_CTX* ctx,const unsigned int timeoutSec,const unsigned int timeoutMic)
{
socket = socketin;
timeout.tv_sec = timeoutSec;
timeout.tv_usec = timeoutMic;
int ssl_int;
if(setsockopt(socket,SOL_SOCKET,SO_RCVTIMEO,reinterpret_cast<char*>(&timeout),sizeof(timeout)) < 0)
throw connection_exception("Set sock opt failed");
ssl = SSL_new(ctx);
bio = BIO_new(BIO_s_socket());
BIO_set_fd(bio,socket,BIO_NOCLOSE);
SSL_set_bio(ssl,bio,bio);
if((ssl_int = SSL_accept(ssl)) < 1)
{
throw connection_exception("SSL Accept failed.");
}
}
开发者ID:Traviis,项目名称:bitcascade-server,代码行数:18,代码来源:connection.cpp
示例20: ssl_server_accept
ssl_server_con * ssl_server_accept(ssl_server_client * scli, int fd){
BIO_set_fd(SSL_get_rbio(scli->ssl), fd, BIO_NOCLOSE);
BIO_ctrl(SSL_get_rbio(scli->ssl), BIO_CTRL_DGRAM_SET_CONNECTED, 0, &scli->addr);
int ret = 0;
do{ret = SSL_accept(scli->ssl);}
while(ret == 0);
if(ret < 0){
handle_ssl_error(scli->ssl, ret);
return NULL;
}
ASSERT(ret > 0);
struct timeval timeout;
timeout.tv_sec = 5;
timeout.tv_usec = 0;
BIO_ctrl(SSL_get_rbio(scli->ssl), BIO_CTRL_DGRAM_SET_RECV_TIMEOUT, 0, &timeout);
ssl_server_con * con = alloc0(sizeof(ssl_server_con));
con->ssl = scli->ssl;
return con;
}
开发者ID:rolfrm,项目名称:UDP-Client,代码行数:19,代码来源:ssl.c
注:本文中的BIO_set_fd函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论