1"""
2websocket - WebSocket client library for Python
3
4Copyright (C) 2010 Hiroki Ohtani(liris)
5
6    This library is free software; you can redistribute it and/or
7    modify it under the terms of the GNU Lesser General Public
8    License as published by the Free Software Foundation; either
9    version 2.1 of the License, or (at your option) any later version.
10
11    This library is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14    Lesser General Public License for more details.
15
16    You should have received a copy of the GNU Lesser General Public
17    License along with this library; if not, write to the Free Software
18    Foundation, Inc., 51 Franklin Street, Fifth Floor,
19    Boston, MA 02110-1335  USA
20
21"""
22__all__ = ["HAVE_SSL", "ssl", "SSLError"]
23
24try:
25    import ssl
26    from ssl import SSLError
27    if hasattr(ssl, 'SSLContext') and hasattr(ssl.SSLContext, 'check_hostname'):
28        HAVE_CONTEXT_CHECK_HOSTNAME = True
29    else:
30        HAVE_CONTEXT_CHECK_HOSTNAME = False
31        if hasattr(ssl, "match_hostname"):
32            from ssl import match_hostname
33        else:
34            from backports.ssl_match_hostname import match_hostname
35        __all__.append("match_hostname")
36    __all__.append("HAVE_CONTEXT_CHECK_HOSTNAME")
37
38    HAVE_SSL = True
39except ImportError:
40    # dummy class of SSLError for ssl none-support environment.
41    class SSLError(Exception):
42        pass
43
44    HAVE_SSL = False
45