当前位置: 首页>>代码示例>>C++>>正文


C++ SSLv3_client_method函数代码示例

本文整理汇总了C++中SSLv3_client_method函数的典型用法代码示例。如果您正苦于以下问题:C++ SSLv3_client_method函数的具体用法?C++ SSLv3_client_method怎么用?C++ SSLv3_client_method使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了SSLv3_client_method函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char *argv[])
{
	SSL_CTX *ctx;
	const SSL_METHOD *method = SSLv3_client_method();
	int client_fd;
	char *host;
	char *portnum;
	int bench_send = 0;
	int bench_recv = 0;
	int i;
	enum cipher_choice cipher_choice = CIPHER_ALL;

	if (argc < 3) {
		printf("Usage: %s <host_ip> <portnum> [opts]\n", argv[0]);
		exit(-1);
	}

	host = argv[1];
	portnum = argv[2];

	lib_init();

	for (i = 3; i < argc; i++) {
		if (strcmp("tls-1.2", argv[i]) == 0) {
			method = TLSv1_2_client_method();
		} else if (strcmp("tls-1.1", argv[i]) == 0) {
			method = TLSv1_1_client_method();
		} else if (strcmp("tls-1.0", argv[i]) == 0) {
			method = TLSv1_client_method();
		} else if (strcmp("ssl-3.0", argv[i]) == 0) {
			method = SSLv3_client_method();
		} else if (strcmp("bench-send", argv[i]) == 0) {
			bench_send = atoi(argv[++i]);
		} else if (strcmp("bench-recv", argv[i]) == 0) {
			bench_recv = atoi(argv[++i]);
		} else {
			printf("warning: unknown option: \"%s\"\n", argv[i]);
		}
	}

	ctx = client_init(method, cipher_choice);

	client_fd = connect_socket(host, atoi(portnum));

	printf("[status] connected. handshaking\n");

	SSL *ssl;
	ssl = SSL_new(ctx);
	SSL_set_fd(ssl, client_fd);

	if (bench_send > 0 || bench_recv > 0)
		benchmark(ssl, bench_send, bench_recv);
	else
		process(ssl);
	close(client_fd);
	SSL_CTX_free(ctx);
	return 0;
}
开发者ID:kazu-yamamoto,项目名称:hs-tls,代码行数:58,代码来源:openssl-client.c

示例2: SSLv23_server_method

const SSL_METHOD *anubis_string_to_SSL_METOHD(const char *method, int role) {
    if(!method)
        return NULL;
    
    if(!strcasecmp(method, "SSLv23"))
        return role == ANUBIS_ROLE_SERVER ?
        SSLv23_server_method() :
        role == ANUBIS_ROLE_CLIENT ? SSLv23_client_method() : NULL;
#ifndef OPENSSL_NO_SSL2_METHOD
    if(!strcasecmp(method, "SSLv2"))
        return role == ANUBIS_ROLE_SERVER ?
        SSLv3_server_method() :
        role == ANUBIS_ROLE_CLIENT ? SSLv3_client_method() : NULL;
#endif
#ifndef OPENSSL_NO_SSL3_METHOD
    if(!strcasecmp(method, "SSLv3"))
        return role == ANUBIS_ROLE_SERVER ?
        SSLv3_server_method() :
        role == ANUBIS_ROLE_CLIENT ? SSLv3_client_method() : NULL;
#endif
    if(!strcasecmp(method, "TLSv1.0"))
        return role == ANUBIS_ROLE_SERVER ?
        TLSv1_server_method() :
        role == ANUBIS_ROLE_CLIENT ? TLSv1_client_method() : NULL;
#if OPENSSL_VERSION_NUMBER >= 0x10001000L
    if(!strcasecmp(method, "TLSv1.1"))
        return role == ANUBIS_ROLE_SERVER ?
        TLSv1_1_server_method() :
        role == ANUBIS_ROLE_CLIENT ? TLSv1_1_client_method() : NULL;
    if(!strcasecmp(method, "TLSv1.2"))
        return role == ANUBIS_ROLE_SERVER ?
        TLSv1_2_server_method() :
        role == ANUBIS_ROLE_CLIENT ? TLSv1_2_client_method() : NULL;
#endif
    
    /*
    if(!strcasecmp(method, "DTLS1.0"))
        return role == ANUBIS_ROLE_SERVER ?
        DTLSv1_server_method() :
        role == ANUBIS_ROLE_CLIENT ? DTLSv1_client_method() : NULL;
    if(!strcasecmp(method, "DTLS1.2"))
        return role == ANUBIS_ROLE_SERVER ?
        DTLSv1_2_server_method() :
        role == ANUBIS_ROLE_CLIENT ? DTLSv1_2_client_method() : NULL;
    if(!strcasecmp(method, "DTLS"))
        return role == ANUBIS_ROLE_SERVER ?
        DTLS_server_method() :
        role == ANUBIS_ROLE_CLIENT ? DTLS_client_method() : NULL;
     */
    
    return NULL;
}//end anubis_string_to_SSL_METOHD
开发者ID:QbsuranAlang,项目名称:Anubis,代码行数:52,代码来源:anubis_value_converter.c

示例3: stream_enable_ssl

/* Initiate an SSL handshake on this stream and encrypt all subsequent data */
int stream_enable_ssl(PTSTREAM *pts) {
#ifdef USE_SSL
	SSL *ssl;
	SSL_CTX *ctx;
	int ret;

	/* Initialise the connection */
	SSLeay_add_ssl_algorithms();
	SSL_load_error_strings();

	ctx = SSL_CTX_new (SSLv3_client_method());
	ssl = SSL_new (ctx);

	if (args_info.verbose_flag) {
		message("Set SNI hostname to %s\n", args_info.proxyhost_arg);
	}
	ret = SSL_set_tlsext_host_name(ssl, args_info.proxyhost_arg);
	if (!ret) {
		message("TLS SNI error, giving up: SSL_set_tlsext_host_name failed\n");
		exit(1);
	}

	SSL_set_rfd (ssl, stream_get_incoming_fd(pts));
	SSL_set_wfd (ssl, stream_get_outgoing_fd(pts));	
	SSL_connect (ssl);

	/* Store ssl and ctx parameters */
	pts->ssl = ssl;
	pts->ctx = ctx;
#else
	message("Warning: stream_open(): SSL stream requested but no SSL support available; using unencrypted connection");
#endif /* USE_SSL */

	return 1;
}
开发者ID:Vaysman,项目名称:proxytunnel,代码行数:36,代码来源:ptstream.c

示例4: init_options

void init_options(void)
{
	if((option.cafiles = malloc(sizeof(char *) * 1)) == (char **) 0)
	{
		fprintf(stderr, "malloc: %.100s (%i)\n", strerror(errno), errno);
		exit(EXIT_FAILURE);
	}

	option.cafiles[0] = 0;

	if((option.log_servers = malloc(sizeof(char *) * 1)) == (char **) 0)
	{
		fprintf(stderr, "malloc: %.100s (%i)\n", strerror(errno), errno);
		exit(EXIT_FAILURE);
	}

	option.log_servers[0] = 0;

	/* default options */
	option.port = 5554;
	option.banner_pause = -1;
	option.facility = LOG_AUTH;
	option.priority = LOG_INFO;
	option.method = SSLv3_client_method();
	option.pemfile = "/etc/eas/certs/client.pem";
	option.egdfile = 0;
	option.randomfile = 0;
	option.cipher = "HIGH:MEDIUM";
	option.method = 0;
	option.default_shell = "/bin/sh";
	option.banner = 0;
	option.tcptimeout = 2;

	return;
}
开发者ID:kdyq007,项目名称:code,代码行数:35,代码来源:clientconf.c

示例5: get_ssl_method_name

int get_ssl_method_name(const SSL_METHOD *ssl_method, char *name, size_t len)
{
	len--;
	name[len] = '\0';
#ifndef OPENSSL_NO_SSL2
	if (ssl_method == SSLv2_client_method()) {
		strncpy(name, "SSLv2", len);
		return 1;
	}
#endif // #ifndef OPENSSL_NO_SSL2
	if (ssl_method == SSLv3_client_method()) {
		strncpy(name, "SSLv3", len);
		return 2;
	}

	if (ssl_method == TLSv1_client_method()) {
		strncpy(name, "TLSv1", len);
		return 3;
	}

#if OPENSSL_VERSION_NUMBER >= 0x1000008fL || OPENSSL_VERSION_NUMBER >= 0x1000100fL
	if (ssl_method == TLSv1_1_client_method()) {
		strncpy(name, "TLS11", len);
		return 4;
	}

	if (ssl_method == TLSv1_2_client_method())
	{
		strncpy(name, "TLS12", len);
		return 5;
	}
#endif // #if OPENSSL_VERSION_NUMBER >= 0x1000008fL || OPENSSL_VERSION_NUMBER >= 0x1000100fL

	return 0;
}
开发者ID:0x4d4e,项目名称:sslscan,代码行数:35,代码来源:helper.c

示例6: _SSL_context_init

SSL_CTX *
_SSL_context_init (void (*info_cb_func), int server)
{
	SSL_CTX *ctx;
#ifdef WIN32
	int i, r;
#endif

	SSLeay_add_ssl_algorithms ();
	SSL_load_error_strings ();
	ctx = SSL_CTX_new (server ? SSLv3_server_method() : SSLv3_client_method ());

	SSL_CTX_set_session_cache_mode (ctx, SSL_SESS_CACHE_BOTH);
	SSL_CTX_set_timeout (ctx, 300);

	/* used in SSL_connect(), SSL_accept() */
	SSL_CTX_set_info_callback (ctx, info_cb_func);

#ifdef WIN32
	/* under win32, OpenSSL needs to be seeded with some randomness */
	for (i = 0; i < 128; i++)
	{
		r = rand ();
		RAND_seed ((unsigned char *)&r, sizeof (r));
	}
#endif

	return(ctx);
}
开发者ID:ArdaXi,项目名称:XChat,代码行数:29,代码来源:ssl.c

示例7: Debug

SSL_METHOD *sycSSLv3_client_method(void) {
   SSL_METHOD *result;
   Debug("SSLv3_client_method()");
   result = SSLv3_client_method();
   Debug1("SSLv3_client_method() -> %p", result);
   return result;
}
开发者ID:dest-unreach,项目名称:socat2,代码行数:7,代码来源:sslcls.c

示例8: init_ssl_methods

/*
 * initialize ssl methods
 */
static void
init_ssl_methods(void)
{
	LM_DBG("entered\n");

#ifndef OPENSSL_NO_SSL2
	ssl_methods[TLS_USE_SSLv2_cli - 1] = (SSL_METHOD*)SSLv2_client_method();
	ssl_methods[TLS_USE_SSLv2_srv - 1] = (SSL_METHOD*)SSLv2_server_method();
	ssl_methods[TLS_USE_SSLv2 - 1] = (SSL_METHOD*)SSLv2_method();
#endif

	ssl_methods[TLS_USE_SSLv3_cli - 1] = (SSL_METHOD*)SSLv3_client_method();
	ssl_methods[TLS_USE_SSLv3_srv - 1] = (SSL_METHOD*)SSLv3_server_method();
	ssl_methods[TLS_USE_SSLv3 - 1] = (SSL_METHOD*)SSLv3_method();

	ssl_methods[TLS_USE_TLSv1_cli - 1] = (SSL_METHOD*)TLSv1_client_method();
	ssl_methods[TLS_USE_TLSv1_srv - 1] = (SSL_METHOD*)TLSv1_server_method();
	ssl_methods[TLS_USE_TLSv1 - 1] = (SSL_METHOD*)TLSv1_method();

	ssl_methods[TLS_USE_SSLv23_cli - 1] = (SSL_METHOD*)SSLv23_client_method();
	ssl_methods[TLS_USE_SSLv23_srv - 1] = (SSL_METHOD*)SSLv23_server_method();
	ssl_methods[TLS_USE_SSLv23 - 1] = (SSL_METHOD*)SSLv23_method();

#if OPENSSL_VERSION_NUMBER >= 0x10001000L
	ssl_methods[TLS_USE_TLSv1_2_cli - 1] = (SSL_METHOD*)TLSv1_2_client_method();
	ssl_methods[TLS_USE_TLSv1_2_srv - 1] = (SSL_METHOD*)TLSv1_2_server_method();
	ssl_methods[TLS_USE_TLSv1_2 - 1] = (SSL_METHOD*)TLSv1_2_method();
#endif

}
开发者ID:abh-gitcs1989,项目名称:opensips,代码行数:33,代码来源:tls_init.c

示例9: sock_SSL_connect

int sock_SSL_connect(SSL **ssl_con, int sockfd)
{
    int ssl_err;
    SSL_CTX *ssl_ctx = NULL;

    ssl_ctx = SSL_CTX_new(SSLv3_client_method());
    if(!ssl_ctx) {
        net_log(NET_LOG_ERR, "sock_SSL_connect: !ssl_ctx\n");
        return WSOCK_ERROR;
    }

    *ssl_con = SSL_new(ssl_ctx);

    if(!(*ssl_con)) {
        net_log(NET_LOG_ERR, "sock_SSL_connect: SSL_new() failed.\n");
        SSL_CTX_free(ssl_ctx);
        return WSOCK_ERROR;
    }
    
    SSL_set_fd (*ssl_con, sockfd);
    SSL_set_connect_state(*ssl_con);
    ssl_err = SSL_connect(*ssl_con);

    if(ssl_err < 0) 
        SSL_set_shutdown(*ssl_con,SSL_SENT_SHUTDOWN);
    if(ssl_err <= 0) {
        net_log(NET_LOG_ERR, "sock_SSL_connect: SSL_connect() failed.\n");
        SSL_free(*ssl_con);
        SSL_CTX_free(ssl_ctx);
        return WSOCK_ERROR;
    }

    return WSOCK_OK;
}
开发者ID:lidongliangfly,项目名称:Libnemesi-reborn,代码行数:34,代码来源:sock_SSL_connect.c

示例10: switch

SSL_CTX* EdSSLContext::buildClientCtx(int ver)
{
	SSL_CTX *pctx;
	const SSL_METHOD *method;
	switch (ver)
	{
	case SSL_VER_TLSV1:
		method = TLSv1_method();
		break;
	case SSL_VER_TLSV11:
		method = TLSv1_1_client_method();
		break;
	case SSL_VER_V23:
		method = SSLv23_client_method();
		break;
	case SSL_VER_V3:
		method = SSLv3_client_method();
		break;
	case SSL_VER_DTLSV1:
		method = DTLSv1_client_method();
		break;
	default:
		method = NULL;
		break;
	}
	if (method == NULL)
		return NULL;

	pctx = SSL_CTX_new(method);

	return pctx;
}
开发者ID:netmindms,项目名称:ednio,代码行数:32,代码来源:EdSSLContext.cpp

示例11: SockSSLConnect

void
SockSSLConnect( struct Sock* out_sock )
{
#ifdef TK_CONFIG_SOCK_SSL_ENABLE
	SSL_CTX*     ctx;
	SSL*         ssl;

	SSL_load_error_strings();
	VCK( SSL_library_init() != 1 ,return);

	ctx = SSL_CTX_new (SSLv3_client_method());
	VCK( ctx == NULL ,return);
	ssl = SSL_new (ctx);
	VCK( ssl == NULL ,return);

	VCK( SSL_set_fd ( ssl, out_sock->socket ) != 1 , return);
	//enable socket SSL

	VCK( SSL_connect (ssl) != 1 ,
			TK_EXCEPTION("SSLConnect failed or be shutdown");
			return);
	//connect SSL

	out_sock->ctx = ctx;
	out_sock->ssl = ssl;
#endif
}
开发者ID:26597925,项目名称:tknet,代码行数:27,代码来源:sock.c

示例12: hb_ssl_method_id_to_ptr

const SSL_METHOD * hb_ssl_method_id_to_ptr( int n )
{
   const SSL_METHOD * p;

   switch( n )
   {
#if OPENSSL_VERSION_NUMBER < 0x10000000L
      case HB_SSL_CTX_NEW_METHOD_SSLV2:         p = SSLv2_method();         break;
      case HB_SSL_CTX_NEW_METHOD_SSLV2_SERVER:  p = SSLv2_server_method();  break;
      case HB_SSL_CTX_NEW_METHOD_SSLV2_CLIENT:  p = SSLv2_client_method();  break;
#endif
      case HB_SSL_CTX_NEW_METHOD_SSLV3:         p = SSLv3_method();         break;
      case HB_SSL_CTX_NEW_METHOD_SSLV3_SERVER:  p = SSLv3_server_method();  break;
      case HB_SSL_CTX_NEW_METHOD_SSLV3_CLIENT:  p = SSLv3_client_method();  break;
      case HB_SSL_CTX_NEW_METHOD_TLSV1:         p = TLSv1_method();         break;
      case HB_SSL_CTX_NEW_METHOD_TLSV1_SERVER:  p = TLSv1_server_method();  break;
      case HB_SSL_CTX_NEW_METHOD_TLSV1_CLIENT:  p = TLSv1_client_method();  break;
      case HB_SSL_CTX_NEW_METHOD_SSLV23:        p = SSLv23_method();        break;
      case HB_SSL_CTX_NEW_METHOD_SSLV23_SERVER: p = SSLv23_server_method(); break;
      case HB_SSL_CTX_NEW_METHOD_SSLV23_CLIENT: p = SSLv23_client_method(); break;
      default: p = SSLv23_method();
   }

   return p;
}
开发者ID:Andygon,项目名称:core,代码行数:25,代码来源:sslctx.c

示例13: us1190_test1

/*
 * This test attempts to create a SSL 3.0 connection
 * with the EST server.  This should fail, as TLS 1.0
 * is not allowed.
 */
static void us1190_test1 (void)
{
    LOG_FUNC_NM
    ;

    us1190_test_sslversion(SSLv3_client_method(), 1);
}
开发者ID:StephenWall,项目名称:libest,代码行数:12,代码来源:us1190.c

示例14: raise_warning

bool SSLSocket::setupCrypto(SSLSocket *session /* = NULL */) {
  if (m_handle) {
    raise_warning("SSL/TLS already set-up for this stream");
    return false;
  }

  /* need to do slightly different things, based on client/server method,
   * so lets remember which method was selected */
#if OPENSSL_VERSION_NUMBER < 0x00909000L
  SSL_METHOD *smethod;
#else
  const SSL_METHOD *smethod;
#endif
  switch (m_method) {
  case ClientSSLv23: m_client = true;  smethod = SSLv23_client_method(); break;
  case ClientSSLv3:  m_client = true;  smethod = SSLv3_client_method();  break;
  case ClientTLS:    m_client = true;  smethod = TLSv1_client_method();  break;
  case ServerSSLv23: m_client = false; smethod = SSLv23_server_method(); break;
  case ServerSSLv3:  m_client = false; smethod = SSLv3_server_method();  break;

  /* SSLv2 protocol might be disabled in the OpenSSL library */
#ifndef OPENSSL_NO_SSL2
  case ClientSSLv2:  m_client = true;  smethod = SSLv2_client_method();  break;
  case ServerSSLv2:  m_client = false; smethod = SSLv2_server_method();  break;
#else
  case ClientSSLv2:
  case ServerSSLv2:
    raise_warning("OpenSSL library does not support SSL2 protocol");
    return false;
  break;
#endif

  case ServerTLS:    m_client = false; smethod = TLSv1_server_method();  break;
  default:
    return false;
  }

  SSL_CTX *ctx = SSL_CTX_new(smethod);
  if (ctx == nullptr) {
    raise_warning("failed to create an SSL context");
    return false;
  }

  SSL_CTX_set_options(ctx, SSL_OP_ALL);
  m_handle = createSSL(ctx);
  if (m_handle == nullptr) {
    raise_warning("failed to create an SSL handle");
    SSL_CTX_free(ctx);
    return false;
  }

  if (!SSL_set_fd(m_handle, m_fd)) {
    handleError(0, true);
  }
  if (session) {
    SSL_copy_session_id(m_handle, session->m_handle);
  }
  return true;
}
开发者ID:524777134,项目名称:hiphop-php,代码行数:59,代码来源:ssl_socket.cpp

示例15: SSL_library_init

bool CSSLClient::Initial(unsigned long encryptionType)
{
	//初始SSL
	s_Lock.Lock();
	if (0 == s_objectCount)
	{
		SSL_library_init();
		const SSL_METHOD * pSSLMethod = NULL;
		if (TVT_ENCRYPTION_SSL == encryptionType)
		{
			pSSLMethod = TLSv1_client_method();
		}
		else if(TVT_ENCRYPTION_TLS == encryptionType)
		{
			pSSLMethod = SSLv3_client_method();
		}

		SSL_load_error_strings();
		s_SSLCTX = SSL_CTX_new(pSSLMethod);
		if(NULL == s_SSLCTX)
		{
			int errNum = ERR_get_error();
			printf("%s:%s:%d, ssl connect error:%s\n", __FUNCTION__, __FILE__, __LINE__, ERR_reason_error_string(errNum));
			printf("%s:%s:%d, error function=%s\n", __FUNCTION__, __FILE__, __LINE__, ERR_func_error_string(errNum));
			s_Lock.UnLock();
			return false;
		}
	/*	if (SSL_CTX_use_certificate_file(s_SSLCTX, CA_CERT_FILE, SSL_FILETYPE_PEM) <= 0)
		{
			printf("Error: %s\n", ERR_reason_error_string(ERR_get_error())); 
			s_Lock.UnLock();
			return false;
		}

		if (SSL_CTX_use_PrivateKey_file_pass(s_SSLCTX, CA_KEY_FILE, "123456") <= 0)
		{
			printf("use_PrivateKey_file err\n");
			s_Lock.UnLock();
			return false;
		}
		*/
		for (int i=0; i < CRYPTO_num_locks(); ++i)
		{
			CPUB_Lock *pLock = new CPUB_Lock;
			s_vecLock.push_back(pLock);
		}

		CRYPTO_set_id_callback(GetThreadId);
		CRYPTO_set_locking_callback(pthreads_locking_callback);

		s_bHasInitial = true;
	}

	s_objectCount++;

	s_Lock.UnLock();

	return true;
}
开发者ID:dulton,项目名称:proxy,代码行数:59,代码来源:SSLClient.cpp


注:本文中的SSLv3_client_method函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。