Thread LWP::UserAgent SSL ausschalten (14 answers)
Opened by bianca at 2015-11-05 08:05

bianca
 2015-11-05 08:05
#182773 #182773
User since
2009-09-13
6978 Artikel
BenutzerIn

user image
Guten Morgen!
Hier im LAN steht ein Apache Webserver auf Windows. Per .htaccess wird auf Port 443 umgeleitet. Zertifikat hab ich keines gemacht, weshalb man im Browser eine Ausnahme hinzugügen muss bevor man mit dem Webserver kommunizieren kann.
Aber wie bringe ich dem CPAN:LWP::UserAgent diese Ausnahme bei?
Probiert hab ich beide Schreibweisen leider ohne Änderung:
Code (perl): (dl )
1
2
3
4
5
6
my $ua = LWP::UserAgent->new(
    ssl_opts        => {
        SSL_verify_mode => SSL_VERIFY_CLIENT_ONCE(),
    },
    SSL_verify_mode => SSL_VERIFY_CLIENT_ONCE(),
);

Der Request geht als GET Methode gegen http://192.168.0.50/cgi-bin/meinscript.pl und funktioniert im Browser genau wie gewünscht, nur mit dem Script nicht. Intern (also über die hosts Datei) ist der auch unter meinserver.net erreichbar.

Ein Trace der Sache sieht so aus:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
DEBUG: .../IO/Socket/SSL.pm:2688: new ctx 54039712
DEBUG: .../IO/Socket/SSL.pm:605: socket not yet connected
DEBUG: .../IO/Socket/SSL.pm:607: socket connected
DEBUG: .../IO/Socket/SSL.pm:629: ssl handshake not started
DEBUG: .../IO/Socket/SSL.pm:662: using SNI with hostname meinserver.net
DEBUG: .../IO/Socket/SSL.pm:697: request OCSP stapling
DEBUG: .../IO/Socket/SSL.pm:716: set socket to non-blocking to enforce timeout=180
DEBUG: .../IO/Socket/SSL.pm:729: call Net::SSLeay::connect
DEBUG: .../IO/Socket/SSL.pm:732: done Net::SSLeay::connect -> -1
DEBUG: .../IO/Socket/SSL.pm:742: ssl handshake in progress
DEBUG: .../IO/Socket/SSL.pm:752: waiting for fd to become ready: SSL wants a read first
DEBUG: .../IO/Socket/SSL.pm:772: socket ready, retrying connect
DEBUG: .../IO/Socket/SSL.pm:729: call Net::SSLeay::connect
DEBUG: .../IO/Socket/SSL.pm:2589: did not get stapled OCSP response
DEBUG: .../IO/Socket/SSL.pm:732: done Net::SSLeay::connect -> -1
DEBUG: .../IO/Socket/SSL.pm:735: SSL connect attempt failed

DEBUG: .../IO/Socket/SSL.pm:735: local error: SSL connect attempt failed error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
DEBUG: .../IO/Socket/SSL.pm:738: fatal SSL error: SSL connect attempt failed error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
DEBUG: .../lib/Net/HTTPS.pm:68: ignoring less severe local error 'IO::Socket::IP configuration failed', keep 'SSL connect attempt failed error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed'
DEBUG: .../IO/Socket/SSL.pm:2721: free ctx 54039712 open=54039712
DEBUG: .../IO/Socket/SSL.pm:2726: free ctx 54039712 callback
DEBUG: .../IO/Socket/SSL.pm:2733: OK free ctx 54039712
500 Can't connect to meinserver.net:443
$VAR1 = bless( {
'_request' => bless( {
'_method' => 'GET',
'_protocol' => undef,
'_headers' => bless( {
'user-agent' => 'libwww-perl/6.13'
}, 'HTTP::Headers' ),
'_content' => '',
'_uri' => bless( do{\(my $o = 'https://meinserver.net/cgi-bin/meinscript.pl')}, 'URI::https' )
}, 'HTTP::Request' ),
'_msg' => 'Can\'t connect to meinserver.net:443',
'_headers' => bless( {
'::std_case' => {
'client-date' => 'Client-Date',
'client-warning' => 'Client-Warning'
},
'content-type' => 'text/plain',
'client-date' => 'Thu, 05 Nov 2015 06:46:04 GMT',
'client-warning' => 'Internal response'
}, 'HTTP::Headers' ),
'_rc' => 500,
'_content' => 'Can\'t connect to meinserver.net:443

Bad file descriptor at C:/strawberry/perl/site/lib/LWP/Protocol/http.pm line 50.
',
'_previous' => bless( {
'_request' => bless( {
'_uri' => bless( do{\(my $o = 'http://192.168.0.50/cgi-bin/meinscript.pl')}, 'URI::http' ),
'_content' => '',
'_uri_canonical' => $VAR1->{'_previous'}{'_request'}{'_uri'},
'_headers' => bless( {
'user-agent' => 'libwww-perl/6.13'
}, 'HTTP::Headers' ),
'_method' => 'GET'
}, 'HTTP::Request' ),
'_protocol' => 'HTTP/1.1',
'_content' => '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="https://meinserver.net/cgi-bin/meinscript.pl">here</a>.</p>
</body></html>
',
'_msg' => 'Found',
'_headers' => bless( {
'vary' => 'Accept-Encoding',
'location' => 'https://meinserver.net/cgi-bin/meinscript.pl',
'connection' => 'close',
'content-length' => '234',
'client-response-num' => 1,
'client-date' => 'Thu, 05 Nov 2015 06:46:03 GMT',
'date' => 'Thu, 05 Nov 2015 06:46:13 GMT',
'x-frame-options' => 'SAMEORIGIN',
'title' => '302 Found',
'client-peer' => '192.168.0.50:80',
'server' => 'Apache/2.2.22 (Win32) mod_ssl/2.2.22 OpenSSL/0.9.8t',
'::std_case' => {
'title' => 'Title',
'client-peer' => 'Client-Peer',
'content-base' => 'Content-Base',
'x-frame-options' => 'X-Frame-Options',
'client-date' => 'Client-Date',
'client-response-num' => 'Client-Response-Num',
'base' => 'Base'
},
'content-type' => 'text/html; charset=iso-8859-1'
}, 'HTTP::Headers' ),
'_rc' => '302'
}, 'HTTP::Response' )
}, 'HTTP::Response' );


Das
Quote
Bad file descriptor at C:/strawberry/perl/site/lib/LWP/Protocol/http.pm line 50.
kennen wir ja noch aus change EAGAIN to EWOULDBLOCK to support Windows too #66, ist gepatcht.

Übrigens: ohne die Umleitung auf Port 443 über die .htaccess klappt alles perfekt. Die Umleitung möchte ich aber aus anderen Gründen drin lassen.
Hab auch versucht, über Firefox das Zertifikat zu exportieren und hier mittels SSL_ca_file einzubinden, das hat leider auch nichts geändert.

Was kann ich machen, dass die Zertifikatsprüfung an der Stelle im Script komplett ausgeschaltet wird?
Last edited: 2015-11-05 08:06:25 +0100 (CET)
10 print "Hallo"
20 goto 10

View full thread LWP::UserAgent SSL ausschalten