1. 用MD5进行校验
当你下载一个软件包后,你应该去校验它,如果你的软件包带有MD5校验码,你可用下面的方法进行校验:
- Linux:
md5sum <package>
- Windows:
CertUtil -hashfile <package>
2. 用GnuPG进行签名校验
一个更加广泛使用的软件包校验工具,它采用加密的签名来进行校验.
- Mysql使用GnuPG,这是一个著名的开放源码项目Pretty Good Privacy (PGP),由Phil Zimmermann创作,可访问http://www.gnupg.org/ 和 [http://www.openpgp.org/]获取更多GnuPG的资料,包括如何配置安装它们在你的系统里.大多数LINUX发行版本已默认安装了GnuPG.
- Windows 上参考 Gpg4win
MYSQL从4.0.10开始对它们的软件包采用GnuPG进行标记,它的内容如下:
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see [http://www.gnupg.org](http://www.gnupg.org/)
mQGiBD4+owwRBAC14GIfUfCyEDSIePvEW3SAFUdJBtoQHH/nJKZyQT7h9bPlUWC3
RODjQReyCITRrdwyrKUGku2FmeVGwn2u2WmDMNABLnpprWPkBdCk96+OmSLN9brZ
fw2vOUgCmYv2hW0hyDHuvYlQA/BThQoADgj8AW6/0Lo7V1W9/8VuHP0gQwCgvzV3
BqOxRznNCRCRxAuAuVztHRcEAJooQK1+iSiunZMYD1WufeXfshc57S/+yeJkegNW
hxwR9pRWVArNYJdDRT+rf2RUe3vpquKNQU/hnEIUHJRQqYHo8gTxvxXNQc7fJYLV
K2HtkrPbP72vwsEKMYhhr0eKCbtLGfls9krjJ6sBgACyP/Vb7hiPwxh6rDZ7ITnE
kYpXBACmWpP8NJTkamEnPCia2ZoOHODANwpUkP43I7jsDmgtobZX9qnrAXw+uNDI
QJEXM6FSbi0LLtZciNlYsafwAPEOMDKpMqAK6IyisNtPvaLd8lH0bPAnWqcyefep
rv0sxxqUEMcM3o7wwgfN83POkDasDbs3pjwPhxvhz6//62zQJ7Q7TXlTUUwgUGFj
a2FnZSBzaWduaW5nIGtleSAod3d3Lm15c3FsLmNvbSkgPGJ1aWxkQG15c3FsLmNv
bT6IXQQTEQIAHQUCP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AAoJEIxxjTtQcuH17p4A
n3r1QpVC9yhnW2cSAjq+kr72GX0eAJ4295kl6NxYEuFApmr1+0uUq/SlsQ==
=YJkx
-----END PGP PUBLIC KEY BLOCK-----
将上面的内容保存成文件,如:mysql.
接下来,你可用gpg --import mysql ,倒入这个构造密钥到公开GPG keyring中.可查看关于公开密钥如何工作的GPG文档来得到更多信息.
在你保存并倒入构造密钥后,现在你需要下载你需要的MYSQL软件包和对应的签名文件.这个签名文件是一个以".asc"为后缀的文件.例如,mysql-standard-4.0.10-gamma-pc-linux-i686.tar.gz'的签名文件是
mysql-standard-4.0.10-gamma-pc-linux-i686.tar.gz.asc'.
保证这两个文件位于同一目录下,再运行下面的命令去校验它.
shell> gpg --verify <package>.asc
举个例子:
shell> gpg --verify mysql-standard-4.0.10-gamma-pc-linux-i686.tar.gz.asc
运行结果:
gpg: Warning: using insecure memory!
gpg: Signature made Mon 03 Feb 2003 08:50:39 PM MET using DSA key ID 5072E1F5
gpg: Good signature from
"MySQL Package signing key (www.mysql.com) build@mysql.com"
"Good signature" 信息说明你的安装包完好.
我下载的最新的mysql-standard-5.0.0-alpha-pc-linux-i686.tar.gz的校验结果.
[root@redsea program]# gpg --verify mysql-standard-5.0.0-alpha-pc-linux-i686.tar.gz.asc
gpg: Signature made 2003年12月24日 星期三 00时13分07秒 CST using DSA key ID 5072E1F5
gpg: Good signature from "MySQL Package signing key (www.mysql.com) build@mysql.com"
gpg: checking the trustdb
gpg: no ultimately trusted keys found
gpg: WARNING: This key is not certified with a trusted signature!
gpg: There is no indication that the signature belongs to the owner.
Primary key fingerprint: A4A9 4068 76FC BD3C 4567 70C8 8C71 8D3B 5072 E1F5
3. 用RPM进行签名校验
针对RPM包的校验.
对于RPM包来说,它没有分离的签名--RPM包实际有一个内置的GPG签名和MD5校验码.你可以校验它用下面的命令:
shell> rpm --checksig <package>.rpm
举个例子:
shell> rpm --checksig MySQL-server-4.0.10-0.i386.rpm
MySQL-server-4.0.10-0.i386.rpm: md5 gpg OK
注意:如果你使用RPM4.1,上面的命令会出现(GPG) NOT OK (MISSING KEYS: GPG#5072e1f5)(即使你曾经倒入过你的GPG密钥).这时你需要首先倒入RPM keyring密钥.RPM 4.1不再使用GPG keyring(和GPG本身),它使用自己的keyring(因为它是系统生成的,而GPG公开密钥是一个用户自定义文件.).
用下面的命令倒入MYSQL公开密钥到RPM keyring中.
shell> rpm --import <pubkey>
举个例子:
shell> rpm --import mysql_pubkey.asc
随后再用--checksig参数进行校验
假如你注意到MD5校验码和GPG数字签名不匹配时,可再次下载正确的软件包,可选用别的镜像服务器.
网友评论