Skip to content

Commit

Permalink
fixed HTTPS proxy support to work with SNI
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Apr 18, 2012
1 parent 64bdc60 commit dfef7b8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
16 changes: 8 additions & 8 deletions lib/Mojo/IOLoop/Client.pm
Expand Up @@ -85,17 +85,17 @@ sub _connect {

# Upgrade
my %options = (
SSL_startHandshake => 0,
SSL_error_trap => sub {
SSL_ca_file => $args->{tls_ca}
&& -T $args->{tls_ca} ? $args->{tls_ca} : undef,
SSL_cert_file => $args->{tls_cert},
SSL_error_trap => sub {
$self->_cleanup;
$self->emit_safe(error => $_[1]);
},
SSL_hostname => $args->{address},
SSL_cert_file => $args->{tls_cert},
SSL_key_file => $args->{tls_key},
SSL_ca_file => $args->{tls_ca}
&& -T $args->{tls_ca} ? $args->{tls_ca} : undef,
SSL_verify_mode => $args->{tls_ca} ? 0x01 : 0x00
SSL_hostname => $args->{address},
SSL_key_file => $args->{tls_key},
SSL_startHandshake => 0,
SSL_verify_mode => $args->{tls_ca} ? 0x01 : 0x00
);
$self->{tls} = 1;
return $self->emit_safe(error => 'TLS upgrade failed.')
Expand Down
6 changes: 3 additions & 3 deletions lib/Mojo/IOLoop/Server.pm
Expand Up @@ -133,9 +133,9 @@ sub listen {

# Options
my $options = $self->{tls} = {
SSL_startHandshake => 0,
SSL_cert_file => $args->{tls_cert} || $self->_cert_file,
SSL_key_file => $args->{tls_key} || $self->_key_file,
SSL_cert_file => $args->{tls_cert} || $self->_cert_file,
SSL_key_file => $args->{tls_key} || $self->_key_file,
SSL_startHandshake => 0
};
%$options = (
%$options,
Expand Down
4 changes: 2 additions & 2 deletions lib/Mojo/Server/Daemon.pm
Expand Up @@ -222,8 +222,8 @@ sub _listen {
my $name = $options->{address} || Sys::Hostname::hostname();
$p->publish(
name => "Mojolicious ($name:$options->{port})",
type => '_http._tcp',
port => $options->{port}
port => $options->{port},
type => '_http._tcp'
) if $options->{port} && !$tls;
}

Expand Down
3 changes: 2 additions & 1 deletion lib/Mojo/UserAgent.pm
Expand Up @@ -202,9 +202,9 @@ sub _connect {
weaken $self;
$id = $self->_loop->client(
address => $host,
port => $port,
handle => $id,
local_address => $self->local_address,
port => $port,
timeout => $self->connect_timeout,
tls => $scheme eq 'https' ? 1 : 0,
tls_ca => $self->ca,
Expand Down Expand Up @@ -251,6 +251,7 @@ sub _connect_proxy {
$loop->remove($id);
weaken $self;
$id = $loop->client(
address => ($self->transactor->peer($old))[1],
handle => $handle,
timeout => $self->connect_timeout,
tls => 1,
Expand Down

0 comments on commit dfef7b8

Please sign in to comment.