问题
I'm using the pycryptodomme
library. The documentation states
All source packages and wheels on PyPI are cryptographically signed. They can be verified with the following PGP key:
I installed it via pip
pip install pycryptodome
I tried just downloading the wheel file directly via
pip download pycryptodome
There isn't a *.sig
or *.asc
file. I don't even see it when I inspect the wheel file directly using the suggestion here.
Question :
How do I check the signature of the wheel file as the documentation suggests?
回答1:
The docs is outdated.
All source packages and wheels on PyPI are cryptographically signed.
That's no longer true. PGP signatures were dropped from PyPI when they switched from old backend to Warehouse:
https://github.com/pypa/warehouse/issues/3356#issuecomment-375303794
https://pyfound.blogspot.com/2018/03/warehouse-all-new-pypi-is-now-in-beta.html
Things that will go away once legacy PyPI shuts down:
GPG/PGP signatures for packages
回答2:
You have to download it manually by getting the URL of the file and then appending .asc
to it.
For example, the borgbackup
project can be viewed here on PyPI's website:
- https://pypi.org/project/borgbackup/
Clicking the "Download Files" button gives you an option to download the lastest tarball at the following URL:
- https://files.pythonhosted.org/packages/97/68/27d96a12f54894223ad6676ce4d215ad61771e3e723580f3ee6e609e17b7/borgbackup-1.1.13.tar.gz
Alternatively, you can also get this URL using cURL against the PyPI "simple" API
user@disp5066:~$ curl -s https://pypi.org/simple/borgbackup/ | grep -i borgbackup-1.1.13.tar.gz
<a href="https://files.pythonhosted.org/packages/97/68/27d96a12f54894223ad6676ce4d215ad61771e3e723580f3ee6e609e17b7/borgbackup-1.1.13.tar.gz#sha256=164a8666a61071ce2fa6c60627c7646f12e3a8e74cd38f046be72f5ea91b3821">borgbackup-1.1.13.tar.gz</a><br/>
user@disp5066:~$
To get the signature of this file, simply append .asc
to the URL:
user@disp5066:~$ wget https://files.pythonhosted.org/packages/97/68/27d96a12f54894223ad6676ce4d215ad61771e3e723580f3ee6e609e17b7/borgbackup-1.1.13.tar.gz.asc
--2020-07-02 07:51:12-- https://files.pythonhosted.org/packages/97/68/27d96a12f54894223ad6676ce4d215ad61771e3e723580f3ee6e609e17b7/borgbackup-1.1.13.tar.gz.asc
Resolving files.pythonhosted.org (files.pythonhosted.org)... 151.101.37.63, 2a04:4e42:9::319
Connecting to files.pythonhosted.org (files.pythonhosted.org)|151.101.37.63|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 862 [application/octet-stream]
Saving to: ‘borgbackup-1.1.13.tar.gz.asc’
borgbackup-1.1.13.t 100%[===================>] 862 --.-KB/s in 0s
2020-07-02 07:51:14 (37.2 MB/s) - ‘borgbackup-1.1.13.tar.gz.asc’ saved [862/862]
user@disp5066:~$ cat borgbackup-1.1.13.tar.gz.asc
-----BEGIN PGP SIGNATURE-----
iQJHBAABCgAxFiEEL4Gv+6sE4R/o7mXUJDrPqVH3jgEFAl7cGqwTHHR3QHdhbGRt
YW5uLWVkdi5kZQAKCRAkOs+pUfeOAd9ND/4nm2O7CK5a4aK41jAI1NisbgEtEJup
SiD6bvMKpo3VU0P/3Y6pUibKOGzaRImBTB04qS3LlgjB0mCp1RSVsj/Hn+yCNw+k
hfUH7E7JgAkq96Vkv1dcYgaJ9nhzuIAkEf0aDyzSo8HkBvGGN0/tfCQ7Nr7hI21u
v5qupIyu7KZrBwY389l7+6yJ9G5qCtHU0fDALRYyjsX+WphrAaizrhFZJO7Km8VZ
gZhAz3WUDPFwgNMb1mToUxpI2ZpnYnRxVBwjnX0Ps77ua4F5OsYM+hYwH5eX9bS9
gmb+W3NjUNjVVj4z+OgN8FGbCTeFVQ6E+IVdm55D4ZRU8KarvFoKOI7HS4GP/3iv
4iWqDaYBMRShnUTk1FKFCKjTb5tXewUGPwio+4bpgUyfJj0OWj1ecMqeF5VAslWz
6pZnsUqLpTFuHUA6dr18TKX4U+c6rdXVM7BhNZe2XtjaQwau6Wz9nC1xhZyFNl1q
CHY7jmLhsfP8GXkh31X9bJrKSZMyYRYat2e7kOroIJczRcHG9T708T+KzsfAb+6w
pWZbfWNfCbCmVQehyhDvNepB3IB5w6ijrZwKTamHAnYBVkAUD/aYwDQJf4nAL4YI
7JXBRpLlCVQGRUQdClqy8QjzpSZs5/Dbetvy5of753JbVjFQtGO2gLLp0wL0HB0v
vIZv3dfBDvfcXQ==
=F4gj
-----END PGP SIGNATURE-----
user@disp5066:~$
See also:
- https://github.com/borgbackup/borg/issues/4213
- https://security.stackexchange.com/questions/232855/does-pythons-pip-provide-cryptographic-authentication-and-integrity-validation
来源:https://stackoverflow.com/questions/62274214/how-do-i-validate-a-pip-packages-pgp-key