Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ssl_options passed into add_with_opts are not honoured #18

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

trevor-indosoft
Copy link

In troubleshooting some issue with multiple https request with SSL_verifycn_scheme set to http, I noticed that only the global ssl_optionswere actually being passed into the Net::HTTPS::NB constructor.

The simply solution was to add the options stored in $args{ssl_opts} back into %args after the global ssl_options are added.

    # Add SSL options, if any, to args
    my $ssl_options = $self->_get_opt('ssl_options');
    @args{ keys %$ssl_options } = values %$ssl_options if $ssl_options;

    # Override global SSL options with request-specific ones, if any
    @args{ keys %{$args{ssl_opts}} } = values %{$args{ssl_opts}} if $args{ssl_opts};

This has allowed me to successfully make requests to multiple sites using hostname verification. Sample:

#!/usr/bin/perl

use HTTP::Async;
use HTTP::Request::Common;
$IO::Socket::SSL::DEBUG = 3;

my $async = HTTP::Async->new(ssl_options => {SSL_verifycn_scheme => 'http'});
$async->add_with_opts(GET('https://site1.example.com'), {ssl_options => {SSL_hostname => 'site1.example.com'}});
$async->add_with_opts(GET('https://site2.example.com'), {ssl_options => {SSL_hostname => 'site2.example.com'}});

while (my $response = $async->wait_for_next_response) {
    print STDOUT $response->request->url . "\n";
    print STDOUT $response->content . "\n";
    print STDOUT $response->code . "\n";
    print STDOUT $response->message . "\n\n";
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants