linkchecker icon indicating copy to clipboard operation
linkchecker copied to clipboard

ImportError: cannot import name get_subj_alt_name

Open edwintorok opened this issue 10 years ago • 16 comments

linkchecker fails on HTTPS URLs in Debian jessie and unstable (wheezy works):

$ linkchecker --version
INFO 2014-12-12 13:42:11,157 MainThread Checking intern URLs only; use --check-extern to check extern URLs.
LinkChecker 9.3 released 16.7.2014
Copyright (C) 2000-2014 Bastian Kleineidam
$ linkchecker -Dall https://www.google.com
[...]
  File "/usr/lib/python2.7/dist-packages/linkcheck/httputil.py", line 35, in x509_to_dict
    line: from requests.packages.urllib3.contrib.pyopenssl import get_subj_alt_name
    locals:
      requests = <not found>
      requests.packages = <not found>
      requests.packages.urllib3 = <not found>
      requests.packages.urllib3.contrib = <not found>
      requests.packages.urllib3.contrib.pyopenssl = <not found>
      get_subj_alt_name = <not found>
ImportError: cannot import name get_subj_alt_name
System info:
LinkChecker 9.3
Released on: 16.7.2014
Python 2.7.9 (default, Dec 11 2014, 08:58:12) 
[GCC 4.9.2] on linux2
Requests: 2.4.3
Qt: 4.8.6 / PyQt: 4.11.2
Modules: Sqlite, Gconf
Local time: 2014-12-12 13:41:22+003
sys.argv: ['/usr/bin/linkchecker', '-Dall', 'https://www.google.com']
LANGUAGE = 'en_US:en'
LANG = 'en_US.UTF-8'
Default locale: ('en', 'UTF-8')

 ******** LinkChecker internal error, over and out ********
WARNING 2014-12-12 13:41:22,177 CheckThread-http://www.google.com/maps/views/sitemap.xml internal error occurred

Full debug output here

edwintorok avatar Dec 12 '14 11:12 edwintorok

me too, with https://docs.arangodb.com/

ImportError: cannot import name get_subj_alt_name System info: LinkChecker 9.3 Released on: 16.7.2014 Python 2.7.9 (default, Mar 1 2015, 12:57:24) [GCC 4.9.2] on linux2 Requests: 2.4.3 Statistics: Downloaded: 0B. No statistics available since no URLs were checked. INFO 2015-03-23 16:16:08,594 MainThread Checking intern URLs only; use --check-extern to check extern URLs. LinkChecker 9.3 Copyright (C) 2000-2014 Bastian Kleineidam

dothebart avatar Mar 23 '15 15:03 dothebart

Me to - appears to be all https sites

Wondering if it is a missing dependency?

xtronics avatar Apr 14 '15 01:04 xtronics

Not sure. I tried manually installing python-urllib3, python-openssl, python3-openssl, as they looked like the obvious candidates for HTTPS connections failing due to an apparently missing library, but didn't seem to fix my Debian linkchecker.

gwern avatar May 01 '15 02:05 gwern

So, I tried to

apt-get install python-urllib3 python-openssl python3-openssl 

but it doesn't fix the issue for me.

dothebart avatar May 04 '15 08:05 dothebart

Hi.

I suggest this change the code of x509_to_dict in /usr/lib/python2.7/dist-packages/linkcheck/httputil.py

By

def x509_to_dict(x509):
    """Parse a x509 pyopenssl object to a dictionary with keys
    subject, subjectAltName and optional notAfter.
    """
    #from requests.packages.urllib3.contrib.pyopenssl import get_subj_alt_name
    import requests.packages.urllib3.contrib.pyopenssl as SSL
    res = {
            'subject': (
                (('commonName', x509.get_subject().CN),),
            ),
            'subjectAltName': [
                ('DNS', value)
                for value in SSL.get_subj_alt_name(x509)
            ]
    }

Linkchecker work fine now.

GwenaelPellenMatelli avatar May 05 '15 06:05 GwenaelPellenMatelli

CHECK! wfm too now.

dothebart avatar May 12 '15 13:05 dothebart

GwenaelPellenMatelli's patch above also seems to fix the problem for me (LinkChecker 9.3 released 16.7.2014, as packaged for Debian 8).

oddhack avatar May 21 '15 21:05 oddhack

this is fixed in #656

anarcat avatar May 19 '16 19:05 anarcat

This error still exists as of yesterday in Ubuntu 15.04. Apparently the Debian Sid version has the patch in it as a NMU, so I installed the Sid .deb and it now works.

gwern avatar Aug 01 '16 15:08 gwern

This error still affects Debian Jessie, as of today.

SilkAndSlug avatar Sep 15 '16 09:09 SilkAndSlug

@SilkAndSlug i could try to make a stable update for this, but i wonder if people can just use w3c-checker instead in jessie...?

anarcat avatar Sep 15 '16 12:09 anarcat

@anarcat : I upgraded to 9.3-4 (Debian Testing), and this problem's gone away.

SilkAndSlug avatar Sep 30 '16 11:09 SilkAndSlug

@SilkAndSlug yes - i had fixed that in Debian in this upload which was migrated to testing end of may.

i'll see if i can make the necessary arrangements to fix this in jessie.

anarcat avatar Sep 30 '16 15:09 anarcat

See #839242 for the jessie update.

anarcat avatar Sep 30 '16 15:09 anarcat

... and it is now in stable-proposed-updates, which you can enable on your jessie machines already, or wait for the next jessie point release.

anarcat avatar Oct 03 '16 13:10 anarcat

Thank you for the issue report. Sadly this project is dead, and a new team is around with https://github.com/linkcheck/linkchecker for more details please see: #708 Also please close this issue and report it freshly on the new repo https://github.com/linkcheck/linkchecker/issues if your issue still persists

dpalic avatar Oct 30 '17 07:10 dpalic