Perl IO::Socket::SSL:连接:网络无法访问 [英] Perl IO::Socket::SSL: connect: Network is unreachable

查看:69
本文介绍了Perl IO::Socket::SSL:连接:网络无法访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何使用 Mail::IMAPClient 的代码都会出现此错误.为了验证我是否使用了该主题中的以下示例:如何进行身份验证使用 Perl 进入 Gmail?

Any code using Mail::IMAPClient is having this error. To verify I have used the below example from the topic: How do I authenticate into Gmail using Perl?

#!/usr/bin/env perl -w
use strict; use warnings;
use Mail::IMAPClient;

# Connect to IMAP server
my $client = Mail::IMAPClient->new(
  Server   => 'imap.gmail.com',
  User     => $user,
  Password => $pass,
  Port     => 993,
  Ssl      =>  1,
  )
  or die "Cannot connect through IMAPClient: $@";

# List folders on remote server (see if all is ok)
if ( $client->IsAuthenticated() ) {
  print "Folders:\n";
  print "- ", $_, "\n" for @{ $client->folders() };  
};

# Say so long
$client->logout();

现在,我经历过类似的问题,但从未见过像网络无法访问"这样的奇怪错误.没有实际的网络问题,ping 工作正常.我安装了 IO::Socket::SSL、Net::SSLeay.

Now, I have gone through questions similar to this but have never seen such a strange error like "Network Unreachable". There is no actual network problem, ping works fine. I have IO::Socket::SSL, Net::SSLeay installed.

$ echo -n |openssl s_client -connect imap.gmail.com:993

$ echo -n | openssl s_client -connect imap.gmail.com:993

CONNECTED(00000003)
depth=2 C = US, O = Equifax, OU = Equifax Secure Certificate Authority
verify return:1
depth=1 C = US, O = Google Inc, CN = Google Internet Authority
verify return:1
depth=0 C = US, ST = California, L = Mountain View, O = Google Inc, CN = imap.gmail.com
verify return:1
---
Certificate chain
 0 s:/C=US/ST=California/L=Mountain View/O=Google Inc/CN=imap.gmail.com
   i:/C=US/O=Google Inc/CN=Google Internet Authority
 1 s:/C=US/O=Google Inc/CN=Google Internet Authority
   i:/C=US/O=Equifax/OU=Equifax Secure Certificate Authority
---
Server certificate
-----BEGIN CERTIFICATE-----
MIIDWzCCAsSgAwIBAgI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PFrrQnQc/BM5H/
kr5ZAyJKHyu4dNnL3NNjig+22fp8slaLo25C95YQT5LiBL2qnAzLs4nWBzqih74=
-----END CERTIFICATE-----
subject=/C=US/ST=California/L=Mountain View/O=Google Inc/CN=imap.gmail.com
issuer=/C=US/O=Google Inc/CN=Google Internet Authority
---
No client certificate CA names sent
---
SSL handshake has read 1850 bytes and written 299 bytes
---
New, TLSv1/SSLv3, Cipher is RC4-SHA
Server public key is 1024 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
SSL-Session:
    Protocol  : TLSv1
    Cipher    : RC4-SHA
    Session-ID: D98F3659858A0F39D32F1B5D96F756DE6E093E849A6AE0066C391BE2881B9A69
    Session-ID-ctx: 
    Master-Key: 8D4BE4DFEB7F3218A501FE9240E0B51CC987B99EE0DDBA5EC13E9A10137B63508692DA684DA25E8B2839906F0F7ADDD5
    Key-Arg   : None
    Krb5 Principal: None
    PSK identity: None
    PSK identity hint: None
    TLS session ticket lifetime hint: 100800 (seconds)
    TLS session ticket:
    0000 - 6e 26 64 bb c3 97 30 9c-32 6f c5 38 d6 db 23 54   n&d...0.2o.8..#T
    0010 - 65 43 b8 01 4e 46 5b b3-81 7e 26 6b 3a 36 2b 62   eC..NF[..~&k:6+b
    0020 - 03 96 44 de 3d b0 81 be-18 b0 14 a1 09 99 28 73   ..D.=.........(s
    0030 - 2d 5a 87 6c b9 26 64 94-af f2 5e f1 f4 10 ba ff   -Z.l.&d...^.....
    0040 - 68 a0 6a 31 d6 10 f8 88-61 63 5a 58 0b 1d d0 98   h.j1....acZX....
    0050 - 81 ed f7 45 11 1d 4a 22-23 2f 44 0c 62 b4 18 e9   ...E..J"#/D.b...
    0060 - e7 4a 57 10 f1 3c a0 d6-ee 46 98 5d df e9 a5 52   .JW..<...F.]...R
    0070 - a6 75 da a6 25 89 87 f0-b0 ec 60 0d c0 19 0e 6f   .u..%.....`....o
    0080 - 23 53 a2 f2 18 e8 8d 51-28 e7 f2 d3 52 8a 02 f4   #S.....Q(...R...
    0090 - 32 aa 82 db                                       2...

    Start Time: 1342180574
    Timeout   : 300 (sec)
    Verify return code: 0 (ok)
---
DONE 

推荐答案

这可能是 ipv6 错误.Gmail 最近启用了 ipv6 访问.您可以尝试将其放在使用 Mail::IMAPClient;"之前吗?行:

this could be an ipv6 error. Gmail enabled ipv6 access recently. Can you try putting this before the 'use Mail::IMAPClient;' line:

use IO::Socket::SSL 'inet4';

这篇关于Perl IO::Socket::SSL:连接:网络无法访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆