Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 2.7 内部网络上的Python SSL验证_Python 2.7_Ssl - Fatal编程技术网

Python 2.7 内部网络上的Python SSL验证

Python 2.7 内部网络上的Python SSL验证,python-2.7,ssl,Python 2.7,Ssl,我在一家公司工作,希望让我的脚本连接到我团队的内部页面并从中提取数据,我的脚本可以连接到我们的外部页面,但任何内部内容都会返回身份验证错误,尽管我的浏览器正在使用这些相同的证书 我用于收集证书的内容: certfile = wincertstore.CertFile() certfile.addstore("CA") certfile.addstore("ROOT") atexit.register(certfile.close) #when looki

我在一家公司工作,希望让我的脚本连接到我团队的内部页面并从中提取数据,我的脚本可以连接到我们的外部页面,但任何内部内容都会返回身份验证错误,尽管我的浏览器正在使用这些相同的证书

我用于收集证书的内容:

certfile = wincertstore.CertFile()
certfile.addstore("CA")
certfile.addstore("ROOT")
atexit.register(certfile.close)

#when looking at which certs are added, I see the ones I need to use are being pulled
如何定义和包装套接字:

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
ssl_sock = ssl.wrap_socket(s,ca_certs=certfile.name, cert_reqs=ssl.CERT_REQUIRED)
连接方式:

def get_site(site):
    response = urllib2.urlopen(site)
    get_site.html = response.read()
    return get_site.html
因为我使用的是windows,所以我正在使用——但除此之外,我想弄清楚这一点,而不必为了可移植性而下载额外的模块

尝试连接到内部站点时,我收到以下错误:

File "C:\Python27\lib\urllib2.py", line 556, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 401: Unauthorized
我的两个问题是:1)这是在服务器端会失效的东西,还是在客户端可能失效的东西?(或者是情境性的?)2)如果这是在我端,我缺少什么才能在内部网页上成功连接


我已经阅读了wincertstore、ssl、socket和urllib2文档,但没有找到任何引用此场景的内容,也没有发现与经历相同场景的人员有关的其他问题,只有一些模糊相关的问题,但最终对我的情况没有用处。

您的代码中没有提供任何身份验证信息,这可能会导致
401未经授权
。不清楚您的应用程序需要什么。但是,如果使用客户端证书进行身份验证,则您必须为这些证书提供
certfile
keyfile
参数,以
wrap\u socket
。您的代码中没有提供任何身份验证信息,这可能会导致
401未经授权
。不清楚您的应用程序需要什么。但如果使用客户端证书进行身份验证,则必须为这些证书提供
certfile
keyfile
参数,以
wrap\u socket