免费的ssl证书申请

免费的ssl证书申请

精选文章moguli202025-03-11 15:11:3123A+A-

免费的 SSL 证书可以通过多种方式申请,其中最常用的是通过 Let's Encrypt 获取。Let's Encrypt 是一个免费、自动化、开放的证书颁发机构(CA),提供了简单易用的工具来申请和管理 SSL/TLS 证书。以下是申请免费 SSL 证书的几种常见方法:


1. 使用 Let's Encrypt 申请 SSL 证书

1.1 使用 Certbot 工具

Certbot 是 Let's Encrypt 官方推荐的自动化工具,支持多种操作系统和 Web 服务器(如 Apache、Nginx 等)。

步骤:

  1. 安装 Certbot

对于 Ubuntu/Debian:

sudo apt update
sudo apt install certbot python3-certbot-nginx # 如果使用 Nginx
sudo apt install certbot python3-certbot-apache # 如果使用 Apache
  1. 对于 CentOS/RHEL:
sudo yum install epel-release
sudo yum install certbot python3-certbot-nginx  # 如果使用 Nginx
sudo yum install certbot python3-certbot-apache # 如果使用 Apache
  1. 申请证书

如果使用 Nginx:

sudo certbot --nginx

如果使用 Apache:

sudo certbot --apache
  1. 如果使用其他 Web 服务器或手动配置:
sudo certbot certonly --standalone -d yourdomain.com -d www.yourdomain.com
  1. 按照提示操作

输入邮箱地址(用于接收证书到期提醒)。

同意服务条款。

选择是否为 HTTP 流量自动重定向到 HTTPS(推荐选择)。

  1. 验证证书

Certbot 会自动配置 Web 服务器并安装证书。

访问 https://yourdomain.com,确认证书已生效。

  1. 自动续期

Let's Encrypt 证书有效期为 90 天,Certbot 会自动设置定时任务续期。

  1. 可以手动测试续期:
sudo certbot renew --dry-run

1.2 使用 acme.sh 工具

acme.sh 是一个轻量级的 ACME 协议客户端,支持多种 DNS 提供商和 Web 服务器。

步骤:

  1. 安装 acme.sh
curl https://get.acme.sh | sh source ~/.bashrc
  1. 申请证书

使用 HTTP 验证:

acme.sh --issue -d yourdomain.com -w /var/www/html

使用 DNS 验证(以 Cloudflare 为例)

export CF_Key="your_cloudflare_api_key" export CF_Email="your_cloudflare_email" acme.sh --issue --dns dns_cf -d yourdomain.com -d www.yourdomain.com
  1. 安装证书

将证书安装到 Nginx 或 Apache 的配置目录:

acme.sh --install-cert -d yourdomain.com \ --key-file /etc/nginx/ssl/yourdomain.com.key \ --fullchain-file /etc/nginx/ssl/yourdomain.com.crt \ --reloadcmd "systemctl reload nginx"
  1. 自动续期

acme.sh 会自动设置定时任务续期证书。


2. 使用其他免费 SSL 证书提供商

除了 Let's Encrypt,还有一些其他免费的 SSL 证书提供商:

2.1 ZeroSSL

  • 提供免费 90 天 SSL 证书。
  • 支持 ACME 协议,可以使用 acme.sh 或 Certbot 申请。
  • 官网:https://zerossl.com

2.2 Cloudflare

  • 如果使用 Cloudflare 的 CDN 服务,可以免费启用 SSL。
  • Cloudflare 提供灵活的 SSL 模式(Full、Full Strict、Flexible)。
  • 官网:https://www.cloudflare.com

2.3 SSL For Free

  • 基于 Let's Encrypt 的免费 SSL 证书服务。
  • 提供简单的 Web 界面申请证书。
  • 官网:https://www.sslforfree.com

3. 手动申请 Let's Encrypt 证书

如果不使用工具,可以手动通过 ACME 协议申请证书。

步骤:

  1. 生成私钥
openssl genrsa -out private.key 4096

2.生成 CSR(证书签名请求):

openssl req -new -key private.key -out csr.pem -subj "/CN=yourdomain.com"

3.使用 ACME 客户端申请证书:

使用 acme.sh 或其他 ACME 客户端提交 CSR 并获取证书。

4.安装证书

将证书和私钥配置到 Web 服务器。


4. 验证 SSL 证书

申请证书后,可以使用以下工具验证证书是否生效:

  • SSL Labs:https://www.ssllabs.com/ssltest/
  • Why No Padlock:https://www.whynopadlock.com/
  • 浏览器访问 https://yourdomain.com,检查地址栏是否有锁标志。

总结

  • Let's Encrypt 是最常用的免费 SSL 证书提供商,支持自动化工具(如 Certbot 和 acme.sh)。
  • 其他免费 SSL 证书提供商包括 ZeroSSL、Cloudflare 和 SSL For Free。
  • 申请证书后,记得配置 Web 服务器并验证证书是否生效。
  • 免费 SSL 证书通常有效期为 90 天,建议设置自动续期。

通过以上方法,你可以轻松为网站启用 HTTPS,提升安全性和用户信任度。

点击这里复制本文地址 以上内容由莫古技术网整理呈现,请务必在转载分享时注明本文地址!如对内容有疑问,请联系我们,谢谢!
qrcode

莫古技术网 © All Rights Reserved.  滇ICP备2024046894号-2