简体   繁体   中英

Using a PFX Certificate to connect to an HTTP site

Here's the scenario: I need to connect to a web site to retrieve electronic lab results formatted in XML. In order to connect, I need to use a digital certificate.

I've been able to get a version of this working in Perl. It looks like this:

#!/usr/bin/env perl

use strict;
use WWW::Mechanize;
$|++;

my $username = 'xxx';
my $password = 'yyy';

$ENV{HTTPS_PKCS12_FILE}     = 'CERTFILE.pfx';
$ENV{HTTPS_PKCS12_PASSWORD} = 'PathCert';

my $mech = WWW::Mechanize->new();
$mech->agent_alias('Windows IE 6');

$mech->get("https://www.example.org/xyz/,DanaInfo=999.33.1.10+");
$mech->get("https://www.example.org/xyz/isapi_pathnet.dll?Page=Login&Mode=Silent&UserID=xxx&Password=yyy,DanaInfo=999.33.1.10");
$mech->get("https://www.example.org/xyz/isapi_pathnet.dll?Page=HL7&Query=NewRequests,DanaInfo=999.33.1.10");

print $mech->content();

Now, this works when I run it from my workstation. However:

  • If I compile it using perl2exe, it doesn't work.
  • If I try to compile it with pp (eg "pp -r sslclient.pl"), all I get back is "500 SSL negotiation failed:"
  • If I copy this whole directory to another computer, the script simply hangs at the first $mech->get() statement.
  • What I really want is to find an equivalent to this in Python (the rest of my app is Python), but so far no luck.

So, plenty of problems here. Anyone have any ideas?

I have no idea what is going on with your perl issues. However, mechanize for Python can be found here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM