加密你的电子邮件

前言

邮件加密?对我们来说很新鲜的词语,平时大家还感受不到,但对于上班族白领来说,邮件的使用频率很高,邮件安全也非常重要。如果某个居心叵测的人,中途截到某一封特别机密或隐私的邮件。哇,有大事情要发生了哦!邮件安全需要我们的重视。

## PGP加密

没什么用的理论知识

PGP加密由一系列散列数据压缩对称密钥加密,以及公钥加密的算法组合而成。每个步骤均支持几种算法,用户可以选择一个使用。每个公钥均绑定一个用户名和/或者E-mail地址。该系统的最初版本通常称为可信网或X.509系统;X.509系统使用的是基于数字证书认证机构的分层方案,该方案后来被加入到PGP的实现中。当前的PGP加密版本通过一个自动密钥管理服务器来进行密钥的可靠存放。

PGP可用于发送机密消息。为此,PGP结合了对称密钥加密和公钥加密。PGP使用对称加密算法对消息进行加密,该算法需要对称密钥。每个对称密钥也称为会话密钥仅被使用一次。消息及其会话密钥被发送到接收方。 会话密钥必须被发送给接收方以解密消息,但是为了在传输过程中保护它,它使用接收方的公钥进行加密。只有属于接收方的私钥才能解密会话密钥。

优点

1.方便

2.安全

3.可以设置过期日期和"撤销"证书

缺点

依靠信赖网络进行验证,这意味着可以随意生成一个任意邮箱的PGP证书

假设没有CA,只信任自己和朋友,每个人都是在一个朋友圈子中,朋友圈子以外的人,则需要一个中间人作为介绍人,这就是现实的生活。
我有一个朋友叫 Andy,且我有另一个朋友叫 Bob,如果 Bob 想认识 Andy,于是他想通过我来认识 Andy,方法很简单,鉴于我认识他们两者,通过我为 Bob 的公钥签名,于是 Andy 可以直接向 Bob 证明他是我的朋友。
PGP 采用的后者是这种方式,每个人都以自己为中心,然后是朋友圈,然后是朋友的朋友。

创建PGP

执行:

gpg --gen-key

反馈:

gpg (GnuPG) 2.2.12; Copyright (C) 2018 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Note: Use "gpg --full-generate-key" for a full featured key generation dialog.

GnuPG needs to construct a user ID to identify your key.

Real name: laoxong
Email address: [email protected]
You selected this USER-ID:
    "laoxong <[email protected]>"

Change (N)ame, (E)mail, or (O)kay/(Q)uit? 
#之后会让你输入密码
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
gpg: /root/.gnupg/trustdb.gpg: trustdb created
gpg: key 21EA5AF745700CB8 marked as ultimately trusted
gpg: directory '/root/.gnupg/openpgp-revocs.d' created
gpg: revocation certificate stored as '/root/.gnupg/openpgp-revocs.d/A21E80E666FC795AD832E40721EA5AF745700CB8.rev'
public and secret key created and signed.

pub   rsa3072 2020-05-21 [SC] [expires: 2022-05-21]
      A21E80E666FC795AD832E40721EA5AF745700CB8
uid                      laoxong <[email protected]>
sub   rsa3072 2020-05-21 [E] [expires: 2022-05-21]

制作撤销证书

# 最好制作一张撤销证书,用于密钥作废,请求外部公钥服务器撤销你的公钥
# 这里 21EA5AF745700CB8 为我的 key id 
gpg --gen-revoke 21EA5AF745700CB8

M/MIME 证书

前言

S/MIME证书是专门加密邮件用的证书(好像也可以加密PDF,没试过),替代了PGP加密,中间有了CA做验证,安全性更高了

没有用的理论知识

安全的多用途Internet邮件扩展Secure Multipurpose Internet Mail Extensions,简称S/MIME)是一种Internet标准,它在安全方面对MIME协议进行了扩展,可以将MIME实体(比如数字签名加密信息等)封装成安全对象,为电子邮件应用增添了消息真实性、完整性和保密性服务。S/MIME不局限于电子邮件,也可以被其他支持MIME的传输机制使用,如HTTP

申请

首先需要购买一个S/MIME证书,或者自己签发(不受信任),要手动设置
免费的证书申请

1.https://certmall.trustauth.cn/
2.https://extrassl.actalis.it/portal/uapub/freemail?lang=en
3.https://freessl.cn/ (1元)

自签名

教程地址:https://www.cnblogs.com/274914765qq/p/4673487.html

我自签的CA,下载:https://lanzous.com/icx62ve

如果你不会签可以找我,将我自签的CA添加信任即可

使用

申请完成后是一个pfx文件

打开之后,直接无脑下一步

之后输入私匙密码,建议勾选强私匙保护之后继续无脑下一步

OUTLOOK 2019的设置

在发送邮件时,勾选签署即可

注:加密需要交换私匙后才能使用,不然对方无法打开

OUTLOOK UWP

默认选择自动即可,若出现问题选择手动,手动指定证书

OUTLOOK自带加密

在选项里面有加密设置

注:个人版和商业版选项有区别

个人:

商业:

效果

参考

https://zh.wikipedia.org/zh-hans/PGP
https://jin-yang.github.io/post/security-pgp-introduce.htmlhttps://jin-yang.github.io/post/security-pgp-introduce.html
https://blog.freessl.cn/how-to-use-smime-with-email/