有关如何从公钥服务器获取公钥的相关查询

有关如何从公钥服务器获取公钥的相关查询

本文介绍了有关如何从公钥服务器获取公钥的相关查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

import urllib

response = urllib.urlopen('http://pool.sks-keyservers.net/')
print 'RESPONSE:', response
print 'URL     :', response.geturl()

headers = response.info()
print 'DATE    :', headers['date']
print 'HEADERS :'
print '---------'
print headers

data = response.read()
print 'LENGTH  :', len(data)
print 'DATA    :'
print '---------'
print data

此代码使我能够看到一些网页信息和内容.我实际上查询的是如何使用 python 函数从任何公钥服务器获取公钥.

This code enable me to see some webpage information and contents.what actually i had query that how to fetch the public key from any public key server using python function.

推荐答案

这个规范应该可以帮助你,并阻止你重复问同样的问题:).基本上,您需要对密钥服务器执行 HTTP GET 请求.大多数关键服务器在 TCP 端口 11371 上工作,因此您需要确保您的防火墙允许您通过.

This spec should help you along, and stop you asking the same question repeatedly :). Basically you need to perform an HTTP GET request to the key server. Most key servers work on TCP port 11371 so you need to ensure that your firewall will let you through.

例如,这个网址会给你上帝的公钥:

For example, this URL will give you God's public key:

http://pool.sks-keyservers.net:11371/pks/lookup?op=get&search=0x1278A1862492D908&options=mr

回应是关键.

在蟒蛇中:

import urllib
f = urllib.urlopen('http://pool.sks-keyservers.net:11371/pks/lookup?op=get&search=0x1278A1862492D908&options=mr')
data = f.read()
print data

-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: SKS 1.1.0

mQGiBD/dywoRBADkaddBEedMhFHGH3wKORuOIDFufSDERmlm2ktj3ma+GhfwvnuvvpAj+QYl
ANh1K86Mm5k0dGOlhZwIr1zB3cIoNqt7TJ62v8w6mc0BA8UWzWJp0i6dHPa/qeeFFC53B8U1
h3FlPrmQGcVeV+hjOPFU7ANDSDm3tduad7NRxAst7QCg/8o++2BaAlTnbMB+Xfo23uEEc6UE
AK0vD4EUPLfU5snfow1zUPXQUDalOcUP6RIhbi6yxKRFAIWI+7QgNPZf/Q2CFIR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cJjxJv2lIATvraXHwNpllOlPHFb9aABHmTOX7QLrG4FXTP
ReH6rjf+w5tqJilTMwYdsZIV13U7+NBwVZHFbUdYMmqhOTiITAQYEQIADAUCP93LCgUbDAAA
AAAKCRASeKGGJJLZCMqJAKCzS0hv0EY/GYdUKOOf3XiiZpu3qwCg9kFBm/GO+t073SsHkedu
HT0F6po=
=NhFO
-----END PGP PUBLIC KEY BLOCK-----

这篇关于有关如何从公钥服务器获取公钥的相关查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 16:10