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

Some problems of graftcp on Ubuntu 20.04. #40

Closed
hongyi-zhao opened this issue Aug 9, 2021 · 6 comments
Closed

Some problems of graftcp on Ubuntu 20.04. #40

hongyi-zhao opened this issue Aug 9, 2021 · 6 comments

Comments

@hongyi-zhao
Copy link

On Ubuntu 20.04, I try to test graftcp with the following example, but failed:

$ sudo gdebi graftcp_0.4.0-1_amd64.deb
$ sudo systemctl disable graftcp-local.service
$ mgraftcp --socks5 127.0.0.1:18889 ipython
Python 3.9.1 (default, Feb 10 2021, 15:30:33) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.23.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import imapclient

In [2]: imapObj = imapclient.IMAPClient('imap.gmail.com', ssl=True)
---------------------------------------------------------------------------
SSLEOFError                               Traceback (most recent call last)
<ipython-input-2-08c6d4884af9> in <module>
----> 1 imapObj = imapclient.IMAPClient('imap.gmail.com', ssl=True)

~/.pyenv/versions/3.9.1/envs/datasci/lib/python3.9/site-packages/imapclient/imapclient.py in __init__(self, host, port, use_uid, ssl, stream, ssl_context, timeout)
    282         self._idle_tag = None
    283 
--> 284         self._imap = self._create_IMAP4()
    285         logger.debug(
    286             "Connected to host %s over %s",

~/.pyenv/versions/3.9.1/envs/datasci/lib/python3.9/site-packages/imapclient/imapclient.py in _create_IMAP4(self)
    319 
    320         if self.ssl:
--> 321             return tls.IMAP4_TLS(
    322                 self.host,
    323                 self.port,

~/.pyenv/versions/3.9.1/envs/datasci/lib/python3.9/site-packages/imapclient/tls.py in __init__(self, host, port, ssl_context, timeout)
     42         self.ssl_context = ssl_context
     43         self._timeout = timeout
---> 44         imaplib.IMAP4.__init__(self, host, port)
     45 
     46     def open(self, host, port=993, timeout=None):

~/.pyenv/versions/3.9.1/lib/python3.9/imaplib.py in __init__(self, host, port, timeout)
    200         # Open socket to server.
    201 
--> 202         self.open(host, port, timeout)
    203 
    204         try:

~/.pyenv/versions/3.9.1/envs/datasci/lib/python3.9/site-packages/imapclient/tls.py in open(self, host, port, timeout)
     50             (host, port), timeout if timeout is not None else self._timeout
     51         )
---> 52         self.sock = wrap_socket(sock, self.ssl_context, host)
     53         self.file = self.sock.makefile("rb")
     54 

~/.pyenv/versions/3.9.1/envs/datasci/lib/python3.9/site-packages/imapclient/tls.py in wrap_socket(sock, ssl_context, host)
     30         ssl_context = ssl.create_default_context(purpose=ssl.Purpose.CLIENT_AUTH)
     31 
---> 32     return ssl_context.wrap_socket(sock, server_hostname=host)
     33 
     34 

~/.pyenv/versions/3.9.1/lib/python3.9/ssl.py in wrap_socket(self, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, session)
    498         # SSLSocket class handles server_hostname encoding before it calls
    499         # ctx._wrap_socket()
--> 500         return self.sslsocket_class._create(
    501             sock=sock,
    502             server_side=server_side,

~/.pyenv/versions/3.9.1/lib/python3.9/ssl.py in _create(cls, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, context, session)
   1038                         # non-blocking
   1039                         raise ValueError("do_handshake_on_connect should not be specified for non-blocking sockets")
-> 1040                     self.do_handshake()
   1041             except (OSError, ValueError):
   1042                 self.close()

~/.pyenv/versions/3.9.1/lib/python3.9/ssl.py in do_handshake(self, block)
   1307             if timeout == 0.0 and block:
   1308                 self.settimeout(None)
-> 1309             self._sslobj.do_handshake()
   1310         finally:
   1311             self.settimeout(timeout)

SSLEOFError: EOF occurred in violation of protocol (_ssl.c:1123)

In [3]: 

OTOH, it really works for Emacs, but I meet some strange messages:

$ mgraftcp --socks5 127.0.0.1:18889 /usr/local/bin/emacs

Then run M-x multi-term RET in Emacs, the following info will be triggered:

sudo: effective uid is not 0, is /usr/bin/sudo on a file system with the 'nosuid' option set or an NFS file system without root privileges?
sudo: effective uid is not 0, is /usr/bin/sudo on a file system with the 'nosuid' option set or an NFS file system without root privileges?

Any hints for these problems?

Regards,
HY

@hmgle
Copy link
Owner

hmgle commented Aug 11, 2021

Can you enable the mgraftcp debug-log with the --enable-debug-log argument and post the relevant log?
For the M-x multi-term RET in Emacs, it may be related to issue #11.

@hongyi-zhao
Copy link
Author

Can you enable the mgraftcp debug-log with the --enable-debug-log argument and post the relevant log?

This time, I try with the latest git master version compiled by myself as follows:

$ git clone https://github.com/hmgle/graftcp.git hmgle/graftcp.git 
$ cd hmgle/graftcp.git 
$ CGO_ENABLED=1 make
$ pyenv shell datasci 
$ ./local/mgraftcp --version
mgraftcp version v0.4.0-2-ge6daf52
$ ./local/mgraftcp --enable-debug-log --socks5 127.0.0.1:18889 ipython
[2021-08-11 16:20:15] [INFO] graftcp-local start listening :0...
Python 3.9.1 (default, Feb 10 2021, 15:30:33) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.23.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import imapclient

In [2]: imapObj = imapclient.IMAPClient('imap.gmail.com', ssl=True)
[2021-08-11 16:20:23] [INFO] Request PID: 1130724, Source Addr: 127.0.0.1:53908, Dest Addr: 108.177.97.108:993
---------------------------------------------------------------------------
SSLEOFError                               Traceback (most recent call last)
<ipython-input-2-08c6d4884af9> in <module>
----> 1 imapObj = imapclient.IMAPClient('imap.gmail.com', ssl=True)

~/.pyenv/versions/3.9.1/envs/datasci/lib/python3.9/site-packages/imapclient/imapclient.py in __init__(self, host, port, use_uid, ssl, stream, ssl_context, timeout)
    282         self._idle_tag = None
    283 
--> 284         self._imap = self._create_IMAP4()
    285         logger.debug(
    286             "Connected to host %s over %s",

~/.pyenv/versions/3.9.1/envs/datasci/lib/python3.9/site-packages/imapclient/imapclient.py in _create_IMAP4(self)
    319 
    320         if self.ssl:
--> 321             return tls.IMAP4_TLS(
    322                 self.host,
    323                 self.port,

~/.pyenv/versions/3.9.1/envs/datasci/lib/python3.9/site-packages/imapclient/tls.py in __init__(self, host, port, ssl_context, timeout)
     42         self.ssl_context = ssl_context
     43         self._timeout = timeout
---> 44         imaplib.IMAP4.__init__(self, host, port)
     45 
     46     def open(self, host, port=993, timeout=None):

~/.pyenv/versions/3.9.1/lib/python3.9/imaplib.py in __init__(self, host, port, timeout)
    200         # Open socket to server.
    201 
--> 202         self.open(host, port, timeout)
    203 
    204         try:

~/.pyenv/versions/3.9.1/envs/datasci/lib/python3.9/site-packages/imapclient/tls.py in open(self, host, port, timeout)
     50             (host, port), timeout if timeout is not None else self._timeout
     51         )
---> 52         self.sock = wrap_socket(sock, self.ssl_context, host)
     53         self.file = self.sock.makefile("rb")
     54 

~/.pyenv/versions/3.9.1/envs/datasci/lib/python3.9/site-packages/imapclient/tls.py in wrap_socket(sock, ssl_context, host)
     30         ssl_context = ssl.create_default_context(purpose=ssl.Purpose.CLIENT_AUTH)
     31 
---> 32     return ssl_context.wrap_socket(sock, server_hostname=host)
     33 
     34 

~/.pyenv/versions/3.9.1/lib/python3.9/ssl.py in wrap_socket(self, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, session)
    498         # SSLSocket class handles server_hostname encoding before it calls
    499         # ctx._wrap_socket()
--> 500         return self.sslsocket_class._create(
    501             sock=sock,
    502             server_side=server_side,

~/.pyenv/versions/3.9.1/lib/python3.9/ssl.py in _create(cls, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, context, session)
   1038                         # non-blocking
   1039                         raise ValueError("do_handshake_on_connect should not be specified for non-blocking sockets")
-> 1040                     self.do_handshake()
   1041             except (OSError, ValueError):
   1042                 self.close()

~/.pyenv/versions/3.9.1/lib/python3.9/ssl.py in do_handshake(self, block)
   1307             if timeout == 0.0 and block:
   1308                 self.settimeout(None)
-> 1309             self._sslobj.do_handshake()
   1310         finally:
   1311             self.settimeout(timeout)

SSLEOFError: EOF occurred in violation of protocol (_ssl.c:1123)

In [3]:

For the M-x multi-term RET in Emacs, it may be related to issue #11.

This still confuses me. Multi-term itself just starts a new terminal from within Emacs. Why is it related to sudo? BTW, I can use proxychains-ng in the similar way without this problem.

@hmgle
Copy link
Owner

hmgle commented Aug 11, 2021

The IP "108.177.97.108" is bad. It looks like you are suffering a DNS cache poisoning attack.
You can check https://github.com/hmgle/graftcp/#i-am-suffering-a-dns-cache-poisoning-attack-does-graftcp-handle-dns-requests

@hmgle hmgle closed this as completed Aug 11, 2021
@hongyi-zhao
Copy link
Author

hongyi-zhao commented Aug 11, 2021

Strange. I use a custom DNS server locally, which can defeat the DNS cache poisoning problem:

$ dig imap.gmail.com +short @127.0.0.1 -p53
74.125.204.108
74.125.204.109

Anyway, see the following testing results again:

$ ./local/mgraftcp --enable-debug-log --socks5 127.0.0.1:18889 ipython
[2021-08-11 20:40:40] [INFO] graftcp-local start listening :0...
Python 3.9.1 (default, Feb 10 2021, 15:30:33) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.23.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import imapclient

In [2]: imapObj = imapclient.IMAPClient('imap.gmail.com', ssl=True)
[2021-08-11 20:40:44] [INFO] Request PID: 2147428, Source Addr: 127.0.0.1:51622, Dest Addr: 74.125.204.109:993
---------------------------------------------------------------------------
SSLEOFError                               Traceback (most recent call last)
<ipython-input-2-08c6d4884af9> in <module>
----> 1 imapObj = imapclient.IMAPClient('imap.gmail.com', ssl=True)

~/.pyenv/versions/3.9.1/envs/datasci/lib/python3.9/site-packages/imapclient/imapclient.py in __init__(self, host, port, use_uid, ssl, stream, ssl_context, timeout)
    282         self._idle_tag = None
    283 
--> 284         self._imap = self._create_IMAP4()
    285         logger.debug(
    286             "Connected to host %s over %s",

~/.pyenv/versions/3.9.1/envs/datasci/lib/python3.9/site-packages/imapclient/imapclient.py in _create_IMAP4(self)
    319 
    320         if self.ssl:
--> 321             return tls.IMAP4_TLS(
    322                 self.host,
    323                 self.port,

~/.pyenv/versions/3.9.1/envs/datasci/lib/python3.9/site-packages/imapclient/tls.py in __init__(self, host, port, ssl_context, timeout)
     42         self.ssl_context = ssl_context
     43         self._timeout = timeout
---> 44         imaplib.IMAP4.__init__(self, host, port)
     45 
     46     def open(self, host, port=993, timeout=None):

~/.pyenv/versions/3.9.1/lib/python3.9/imaplib.py in __init__(self, host, port, timeout)
    200         # Open socket to server.
    201 
--> 202         self.open(host, port, timeout)
    203 
    204         try:

~/.pyenv/versions/3.9.1/envs/datasci/lib/python3.9/site-packages/imapclient/tls.py in open(self, host, port, timeout)
     50             (host, port), timeout if timeout is not None else self._timeout
     51         )
---> 52         self.sock = wrap_socket(sock, self.ssl_context, host)
     53         self.file = self.sock.makefile("rb")
     54 

~/.pyenv/versions/3.9.1/envs/datasci/lib/python3.9/site-packages/imapclient/tls.py in wrap_socket(sock, ssl_context, host)
     30         ssl_context = ssl.create_default_context(purpose=ssl.Purpose.CLIENT_AUTH)
     31 
---> 32     return ssl_context.wrap_socket(sock, server_hostname=host)
     33 
     34 

~/.pyenv/versions/3.9.1/lib/python3.9/ssl.py in wrap_socket(self, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, session)
    498         # SSLSocket class handles server_hostname encoding before it calls
    499         # ctx._wrap_socket()
--> 500         return self.sslsocket_class._create(
    501             sock=sock,
    502             server_side=server_side,

~/.pyenv/versions/3.9.1/lib/python3.9/ssl.py in _create(cls, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, context, session)
   1038                         # non-blocking
   1039                         raise ValueError("do_handshake_on_connect should not be specified for non-blocking sockets")
-> 1040                     self.do_handshake()
   1041             except (OSError, ValueError):
   1042                 self.close()

~/.pyenv/versions/3.9.1/lib/python3.9/ssl.py in do_handshake(self, block)
   1307             if timeout == 0.0 and block:
   1308                 self.settimeout(None)
-> 1309             self._sslobj.do_handshake()
   1310         finally:
   1311             self.settimeout(timeout)

SSLEOFError: EOF occurred in violation of protocol (_ssl.c:1123)

In [3]: 

@hmgle
Copy link
Owner

hmgle commented Aug 11, 2021

My machine cannot reproduce this problem.
Can you test your socks5 proxy by curl -x socks5h://127.0.0.1:18889 http://www.google.com/?
Or try to specify the proxy_mode: ./local/mgraftcp --enable-debug-log --select_proxy_mode=only_socks5 --socks5 127.0.0.1:18889 ipython.

@hongyi-zhao
Copy link
Author

hongyi-zhao commented Aug 11, 2021

Can you test your socks5 proxy by curl -x socks5h://127.0.0.1:18889 http://www.google.com/?

$ curl -vIx socks5h://127.0.0.1:18889 http://www.google.com/
*   Trying 127.0.0.1:18889...
* TCP_NODELAY set
* SOCKS5 communication to www.google.com:80
* SOCKS5 connect to www.google.com:80 (remotely resolved)
* SOCKS5 request granted.
* Connected to 127.0.0.1 (127.0.0.1) port 18889 (#0)
> HEAD / HTTP/1.1
> Host: www.google.com
> User-Agent: curl/7.68.0
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
HTTP/1.1 200 OK
< Content-Type: text/html; charset=ISO-8859-1
Content-Type: text/html; charset=ISO-8859-1
< P3P: CP="This is not a P3P policy! See g.co/p3phelp for more info."
P3P: CP="This is not a P3P policy! See g.co/p3phelp for more info."
< Date: Wed, 11 Aug 2021 13:39:16 GMT
Date: Wed, 11 Aug 2021 13:39:16 GMT
< Server: gws
Server: gws
< X-XSS-Protection: 0
X-XSS-Protection: 0
< X-Frame-Options: SAMEORIGIN
X-Frame-Options: SAMEORIGIN
< Transfer-Encoding: chunked
Transfer-Encoding: chunked
< Expires: Wed, 11 Aug 2021 13:39:16 GMT
Expires: Wed, 11 Aug 2021 13:39:16 GMT
< Cache-Control: private
Cache-Control: private
< Set-Cookie: 1P_JAR=2021-08-11-13; expires=Fri, 10-Sep-2021 13:39:16 GMT; path=/; domain=.google.com; Secure
Set-Cookie: 1P_JAR=2021-08-11-13; expires=Fri, 10-Sep-2021 13:39:16 GMT; path=/; domain=.google.com; Secure
< Set-Cookie: NID=221=pB__Nw0rBFt8zqBliNZ-hWQlifzaym76gbveCiZoCXq_e_vn5pdSxxe2AkcAVgY3glxjFWfPclCWBG_UTfnwpiPpLqzgv5-dVXtBAGhzIV8bMwqQPG9aEs63kqFyd_GENPpUz0Yqv8zILGRSvaUjCPTTursGZzsqUKKtixJgUyw; expires=Thu, 10-Feb-2022 13:39:16 GMT; path=/; domain=.google.com; HttpOnly
Set-Cookie: NID=221=pB__Nw0rBFt8zqBliNZ-hWQlifzaym76gbveCiZoCXq_e_vn5pdSxxe2AkcAVgY3glxjFWfPclCWBG_UTfnwpiPpLqzgv5-dVXtBAGhzIV8bMwqQPG9aEs63kqFyd_GENPpUz0Yqv8zILGRSvaUjCPTTursGZzsqUKKtixJgUyw; expires=Thu, 10-Feb-2022 13:39:16 GMT; path=/; domain=.google.com; HttpOnly

< 
* Connection #0 to host 127.0.0.1 left intact

Or try to specify the proxy_mode: ./local/mgraftcp --enable-debug-log --select_proxy_mode=only_socks5 --socks5 127.0.0.1:18889 ipython.

Strange, mgraftcp sometimes use, sometimes doesn't use my DNS server:

$ ./local/mgraftcp --enable-debug-log --select_proxy_mode=only_socks5 --socks5 127.0.0.1:18889 ipython
[2021-08-11 21:41:06] [INFO] graftcp-local start listening :0...
Python 3.9.1 (default, Feb 10 2021, 15:30:33) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.23.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import imapclient

In [2]: imapObj = imapclient.IMAPClient('imap.gmail.com', ssl=True)
[2021-08-11 21:41:10] [INFO] Request PID: 592488, Source Addr: 127.0.0.1:58572, Dest Addr: 108.177.125.108:993
---------------------------------------------------------------------------
SSLEOFError                               Traceback (most recent call last)
<ipython-input-2-08c6d4884af9> in <module>
----> 1 imapObj = imapclient.IMAPClient('imap.gmail.com', ssl=True)

~/.pyenv/versions/3.9.1/envs/datasci/lib/python3.9/site-packages/imapclient/imapclient.py in __init__(self, host, port, use_uid, ssl, stream, ssl_context, timeout)
    282         self._idle_tag = None
    283 
--> 284         self._imap = self._create_IMAP4()
    285         logger.debug(
    286             "Connected to host %s over %s",

~/.pyenv/versions/3.9.1/envs/datasci/lib/python3.9/site-packages/imapclient/imapclient.py in _create_IMAP4(self)
    319 
    320         if self.ssl:
--> 321             return tls.IMAP4_TLS(
    322                 self.host,
    323                 self.port,

~/.pyenv/versions/3.9.1/envs/datasci/lib/python3.9/site-packages/imapclient/tls.py in __init__(self, host, port, ssl_context, timeout)
     42         self.ssl_context = ssl_context
     43         self._timeout = timeout
---> 44         imaplib.IMAP4.__init__(self, host, port)
     45 
     46     def open(self, host, port=993, timeout=None):

~/.pyenv/versions/3.9.1/lib/python3.9/imaplib.py in __init__(self, host, port, timeout)
    200         # Open socket to server.
    201 
--> 202         self.open(host, port, timeout)
    203 
    204         try:

~/.pyenv/versions/3.9.1/envs/datasci/lib/python3.9/site-packages/imapclient/tls.py in open(self, host, port, timeout)
     50             (host, port), timeout if timeout is not None else self._timeout
     51         )
---> 52         self.sock = wrap_socket(sock, self.ssl_context, host)
     53         self.file = self.sock.makefile("rb")
     54 

~/.pyenv/versions/3.9.1/envs/datasci/lib/python3.9/site-packages/imapclient/tls.py in wrap_socket(sock, ssl_context, host)
     30         ssl_context = ssl.create_default_context(purpose=ssl.Purpose.CLIENT_AUTH)
     31 
---> 32     return ssl_context.wrap_socket(sock, server_hostname=host)
     33 
     34 

~/.pyenv/versions/3.9.1/lib/python3.9/ssl.py in wrap_socket(self, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, session)
    498         # SSLSocket class handles server_hostname encoding before it calls
    499         # ctx._wrap_socket()
--> 500         return self.sslsocket_class._create(
    501             sock=sock,
    502             server_side=server_side,

~/.pyenv/versions/3.9.1/lib/python3.9/ssl.py in _create(cls, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, context, session)
   1038                         # non-blocking
   1039                         raise ValueError("do_handshake_on_connect should not be specified for non-blocking sockets")
-> 1040                     self.do_handshake()
   1041             except (OSError, ValueError):
   1042                 self.close()

~/.pyenv/versions/3.9.1/lib/python3.9/ssl.py in do_handshake(self, block)
   1307             if timeout == 0.0 and block:
   1308                 self.settimeout(None)
-> 1309             self._sslobj.do_handshake()
   1310         finally:
   1311             self.settimeout(timeout)

SSLEOFError: EOF occurred in violation of protocol (_ssl.c:1123)

In [3]: 

Sometimes IPv6 address is returned, but still failed:

$ mgraftcp --enable-debug-log --select_proxy_mode=only_socks5 --socks5 127.0.0.1:18889 ipython
[2021-08-11 22:24:31] [INFO] graftcp-local start listening :0...
Python 3.9.1 (default, Feb 10 2021, 15:30:33) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.23.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import imapclient

In [2]: imapObj = imapclient.IMAPClient('imap.gmail.com', ssl=True)
[2021-08-11 22:24:34] [INFO] Request PID: 2474485, Source Addr: [::1]:60402, Dest Addr: [2a00:1450:4013:c16::6c]:993
---------------------------------------------------------------------------
SSLEOFError                               Traceback (most recent call last)
<ipython-input-2-08c6d4884af9> in <module>
----> 1 imapObj = imapclient.IMAPClient('imap.gmail.com', ssl=True)

~/.pyenv/versions/3.9.1/envs/datasci/lib/python3.9/site-packages/imapclient/imapclient.py in __init__(self, host, port, use_uid, ssl, stream, ssl_context, timeout)
    282         self._idle_tag = None
    283 
--> 284         self._imap = self._create_IMAP4()
    285         logger.debug(
    286             "Connected to host %s over %s",

~/.pyenv/versions/3.9.1/envs/datasci/lib/python3.9/site-packages/imapclient/imapclient.py in _create_IMAP4(self)
    319 
    320         if self.ssl:
--> 321             return tls.IMAP4_TLS(
    322                 self.host,
    323                 self.port,

~/.pyenv/versions/3.9.1/envs/datasci/lib/python3.9/site-packages/imapclient/tls.py in __init__(self, host, port, ssl_context, timeout)
     42         self.ssl_context = ssl_context
     43         self._timeout = timeout
---> 44         imaplib.IMAP4.__init__(self, host, port)
     45 
     46     def open(self, host, port=993, timeout=None):

~/.pyenv/versions/3.9.1/lib/python3.9/imaplib.py in __init__(self, host, port, timeout)
    200         # Open socket to server.
    201 
--> 202         self.open(host, port, timeout)
    203 
    204         try:

~/.pyenv/versions/3.9.1/envs/datasci/lib/python3.9/site-packages/imapclient/tls.py in open(self, host, port, timeout)
     50             (host, port), timeout if timeout is not None else self._timeout
     51         )
---> 52         self.sock = wrap_socket(sock, self.ssl_context, host)
     53         self.file = self.sock.makefile("rb")
     54 

~/.pyenv/versions/3.9.1/envs/datasci/lib/python3.9/site-packages/imapclient/tls.py in wrap_socket(sock, ssl_context, host)
     30         ssl_context = ssl.create_default_context(purpose=ssl.Purpose.CLIENT_AUTH)
     31 
---> 32     return ssl_context.wrap_socket(sock, server_hostname=host)
     33 
     34 

~/.pyenv/versions/3.9.1/lib/python3.9/ssl.py in wrap_socket(self, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, session)
    498         # SSLSocket class handles server_hostname encoding before it calls
    499         # ctx._wrap_socket()
--> 500         return self.sslsocket_class._create(
    501             sock=sock,
    502             server_side=server_side,

~/.pyenv/versions/3.9.1/lib/python3.9/ssl.py in _create(cls, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, context, session)
   1038                         # non-blocking
   1039                         raise ValueError("do_handshake_on_connect should not be specified for non-blocking sockets")
-> 1040                     self.do_handshake()
   1041             except (OSError, ValueError):
   1042                 self.close()

~/.pyenv/versions/3.9.1/lib/python3.9/ssl.py in do_handshake(self, block)
   1307             if timeout == 0.0 and block:
   1308                 self.settimeout(None)
-> 1309             self._sslobj.do_handshake()
   1310         finally:
   1311             self.settimeout(timeout)

SSLEOFError: EOF occurred in violation of protocol (_ssl.c:1123)

In [3]: 

I also tried with the real IP, but still failed:

In [6]: imapObj = imapclient.IMAPClient('108.177.97.109', ssl=True)
[2021-08-12 09:45:00] [INFO] Request PID: 1324611, Source Addr: 127.0.0.1:42756, Dest Addr: 108.177.97.109:993
---------------------------------------------------------------------------
SSLEOFError                               Traceback (most recent call last)
<ipython-input-6-e0bc17fab56b> in <module>
----> 1 imapObj = imapclient.IMAPClient('108.177.97.109', ssl=True)

~/.pyenv/versions/3.9.1/envs/datasci/lib/python3.9/site-packages/imapclient/imapclient.py in __init__(self, host, port, use_uid, ssl, stream, ssl_context, timeout)
    282         self._idle_tag = None
    283 
--> 284         self._imap = self._create_IMAP4()
    285         logger.debug(
    286             "Connected to host %s over %s",

~/.pyenv/versions/3.9.1/envs/datasci/lib/python3.9/site-packages/imapclient/imapclient.py in _create_IMAP4(self)
    319 
    320         if self.ssl:
--> 321             return tls.IMAP4_TLS(
    322                 self.host,
    323                 self.port,

~/.pyenv/versions/3.9.1/envs/datasci/lib/python3.9/site-packages/imapclient/tls.py in __init__(self, host, port, ssl_context, timeout)
     42         self.ssl_context = ssl_context
     43         self._timeout = timeout
---> 44         imaplib.IMAP4.__init__(self, host, port)
     45 
     46     def open(self, host, port=993, timeout=None):

~/.pyenv/versions/3.9.1/lib/python3.9/imaplib.py in __init__(self, host, port, timeout)
    200         # Open socket to server.
    201 
--> 202         self.open(host, port, timeout)
    203 
    204         try:

~/.pyenv/versions/3.9.1/envs/datasci/lib/python3.9/site-packages/imapclient/tls.py in open(self, host, port, timeout)
     50             (host, port), timeout if timeout is not None else self._timeout
     51         )
---> 52         self.sock = wrap_socket(sock, self.ssl_context, host)
     53         self.file = self.sock.makefile("rb")
     54 

~/.pyenv/versions/3.9.1/envs/datasci/lib/python3.9/site-packages/imapclient/tls.py in wrap_socket(sock, ssl_context, host)
     30         ssl_context = ssl.create_default_context(purpose=ssl.Purpose.CLIENT_AUTH)
     31 
---> 32     return ssl_context.wrap_socket(sock, server_hostname=host)
     33 
     34 

~/.pyenv/versions/3.9.1/lib/python3.9/ssl.py in wrap_socket(self, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, session)
    498         # SSLSocket class handles server_hostname encoding before it calls
    499         # ctx._wrap_socket()
--> 500         return self.sslsocket_class._create(
    501             sock=sock,
    502             server_side=server_side,

~/.pyenv/versions/3.9.1/lib/python3.9/ssl.py in _create(cls, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, context, session)
   1038                         # non-blocking
   1039                         raise ValueError("do_handshake_on_connect should not be specified for non-blocking sockets")
-> 1040                     self.do_handshake()
   1041             except (OSError, ValueError):
   1042                 self.close()

~/.pyenv/versions/3.9.1/lib/python3.9/ssl.py in do_handshake(self, block)
   1307             if timeout == 0.0 and block:
   1308                 self.settimeout(None)
-> 1309             self._sslobj.do_handshake()
   1310         finally:
   1311             self.settimeout(timeout)

SSLEOFError: EOF occurred in violation of protocol (_ssl.c:1123)

In [7]: 

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

No branches or pull requests

2 participants