コード例 #1
0
ファイル: ptstream.c プロジェクト: thieso2/proxytunnel
/* Initiate an SSL handshake on this stream and encrypt all subsequent data */
int stream_enable_ssl(PTSTREAM *pts) {
#ifdef USE_SSL
	SSL_METHOD *meth;
	SSL *ssl;
	SSL_CTX *ctx;
	
	/* Initialise the connection */
	SSLeay_add_ssl_algorithms();
	meth = TLSv1_client_method();
	SSL_load_error_strings();

	ctx = SSL_CTX_new (meth);
	ssl = SSL_new (ctx);
	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;
}
コード例 #2
0
ファイル: ptstream.c プロジェクト: Vaysman/proxytunnel
/* 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;
}
コード例 #3
0
ファイル: ptstream.c プロジェクト: dagwieers/proxytunnel
/* Initiate an SSL handshake on this stream and encrypt all subsequent data */
int stream_enable_ssl(PTSTREAM *pts) {
#ifdef USE_SSL
	const SSL_METHOD *meth;
	SSL *ssl;
	SSL_CTX *ctx;
	long res = 1;
	
	/* Initialise the connection */
	SSLeay_add_ssl_algorithms();
	if (args_info.enforcetls1_flag) {
		meth = TLSv1_client_method();
	} else {
		meth = SSLv23_client_method();
	}
	SSL_load_error_strings();

	ctx = SSL_CTX_new (meth);
	ssl = SSL_new (ctx);
	
	SSL_set_rfd (ssl, stream_get_incoming_fd(pts));
	SSL_set_wfd (ssl, stream_get_outgoing_fd(pts));	

	/* SNI support */
	if ( args_info.verbose_flag ) {
           message( "Set SNI hostname to %s\n", args_info.proxyhost_arg );
    }
	res = SSL_set_tlsext_host_name(ssl,args_info.proxyhost_arg);
	if (res < 0) {
	   message( "TLS SNI error, giving up: SSL_set_tlsext_host_name returned error message:\n  %u\n", res );
	   exit( 1 );
	}
	
	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;
}