GitHub 学生包: Namecheap 一年免费SSL证书

本文最后更新于:2022年10月4日 晚上

GitHub学生包赠送name.com免费一年的SSL证书。

福利介绍

SSL 证书是一个数字证书,用于认证网站的身份并启用加密连接。一般我们都用免费的,当然能用,但往往几个月就会过期。而且别人一查,会发现证书可信度不够高。name.com的证书,原价10美元一年。可以通过学生包免费薅到,岂不乐哉。

领取

首先在GitHub学生包页面生成offer code:

之后点击Namecheap网站购买SSL证书,填入优惠码即可免费。

激活SSL证书

首先在服务器上生成CSR,参考这篇文章如何制作CSR文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
[root@host]# openssl req -new -nodes -sha256 -newkey rsa:2048 -keyout your_private.key -out CSR
Generating a RSA private key
......................+++++
.................................................+++++
writing new private key to '[]'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:CN
State or Province Name (full name) []:Beijing
Locality Name (eg, city) [Default City]:Beijing
Organization Name (eg, company) [Default Company Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (eg, your name or your server's hostname) []:host
Email Address []:[email protected]

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:NferwjIEDRW
An optional company name []:
  • Organization Name:公司名称,可以是中文或英文。
  • Organization Unit Name:部门名称,可以是中文或英文。
  • Country Code:申请单位所属国家,只能是两个字母的国家码。例如,中国只能是CN。
  • State or Province:州名或省份名称,可以是中文或英文。
  • Locality:城市名称,可以是中文或英文。
  • Common Name:申请SSL证书的具体网站域名。
  • Email Address:可选择不输入。
  • A challenge password:可选择不输入。

会生成两个文件,一个your_private.key,一个CSR,其中CSR上传到namecheap网站,your_private.key则保留在服务器上,之后会用到。

在下面填入CSR内容:

1
2
3
-----BEGIN CERTIFICATE REQUEST-----
类似于这样的格式
-----END CERTIFICATE REQUEST-----

然后选择验证方式,如果有域名邮箱,可以直接用域名邮箱进行验证即可。

证书安装

根据Namecheap的官方安装教程,有很多种选择,这里我们选择手动配置Nginx进行安装。

配置Nginx

下载证书文件到服务器:

将两个文件的内容(your_domain.crt 和 your_domain.ca-bundle)合并到一个crt文件中:

1
cat your_domain.crt your_domain.ca-bundle >> your_domain_chain.crt

修改证书路径:

1
2
3
ssl_certificate /path/to/certificate/your_domain_chain.crt;

ssl_certificate_key /path/to/your_private.key;

重启Nginx即可

验证配置文件是否正确:

1
2
3
$ nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

重启:

1
systemctl reload nginx

GitHub 学生包: Namecheap 一年免费SSL证书
https://pawswrite.xyz/posts/15759.html
作者
Rainbow
发布于
2022年6月9日
许可协议