php - 是否可以使用 PHP 使 Apache 重新加载 SSL 证书,而无需 shell 访问?

标签 php apache ssl

我刚找到 Let's Encrypt ,同时寻找 notorious 的替代品StartSSL,用于管理我的 DV SSL 证书。由于 LE 证书是短暂的,I'd like to使续订过程自动化。

我没有 shell 访问权限(只有 cPanel),也没有来 self 的托管服务提供商的内置 LE 支持,所以 Certbot 处于手动模式 seems to be唯一的出路。

我注意到 cPanel 的 /ssl/certs/ 目录,其中包含我所有的证书。现在我正在考虑一个 Cron 作业来运行一个 PHP 脚本来获取新证书并覆盖过期的证书,但我不确定这是否可行,因为我需要让 Apache 重新加载被覆盖的证书。是否可能,使用 PHP?

最佳答案

手动获取证书

Dislaimer. Letsencrypt says: We don’t recommend this option because it is time-consuming and you will need to repeat it several times per year as your certificate expires. For most people it is better to request Let’s Encrypt support from your hosting provider, or switch providers if they do not plan to implement it.

Dislaimer 2. I don't actually have access to a cPanel server so I'm unable to test this. There may be errors. Please let me know and I'll correct them.

  1. 安装 certbot在您的本地计算机上
  2. 生成质询响应:
    $ certbot certonly --manual -d example.com --test-cert --staging

    (注意:删除 --test-cert --staging 以获得有效证书)
  3. 然后您应该会看到如下内容:

    Make sure your web server displays the following content at http://example.com/.well-known/acme-challenge/VnHBr_PVGfhu-jdX0NCKrgAcCeC9A-HVqFjMOUAf24Y before continuing:

    VnHBr_PVGfhu-jdX0NCKrgAcCeC9A-HVqFjMOUAf24Y.0l4s1uvmfEFHST9EqeW_AnsdrM7GmE0joLEjRGruG-8

  4. 根据需要手动创建文件并将其上传到您的网络根目录
  5. 返回您的计算机并按 Enter 继续

如果一切顺利,您应该拥有一个 Shiny 的新 SSL 证书。

安装 SSL 服务器证书文件

  1. 登录控制面板
  2. 点击 SSL/TLS 管理器 > 证书 (CRT) > 生成、查看、上传或删除 SSL 证书
  3. 在“上传新证书”部分单击“浏览”按钮并找到您的 SSL 服务器证书文件。我相信这应该是 /etc/letsencrypt/live/example.com/cert.pem
  4. 点击“上传”按钮。
  5. 单击“返回”链接返回到 SSL/TLS 管理器。

注意:我在上面的说明中没有看到任何提到如何处理私钥的内容,但是 this site在某处提到“上传新私钥”链接。无论你想把你的私钥放在那里。

设置域

  1. 点击 SSL/TLS 管理器 > 设置 SSL 证书以使用您的网站。如果您无法使用此选项,您的 ISP 可能已将其禁用,您需要联系他们以完成 SSL 设置。
  2. 从域下拉菜单中选择将使用 SSL 证书的域。系统将尝试获取 SSL 证书和相应的私钥。
  3. 在记事本或其他简单的文本编辑器(不是 Word)中打开 Letsencrypt 中间 key (/etc/letsencrypt/live/example.com/fullchain.pem)。将此文件的所有内容复制并粘贴到 Ca Bundle (CABUNDLE) 框中。
  4. 点击安装证书。您应该会收到一条消息,表明证书已成功安装。如果您收到错误消息,您可能需要联系您的网络托管服务提供商以获得更多支持。

成功安装证书后,cPanel 应重新启动/重新加载网络服务器,以便证书生效。

改编自here .

关于php - 是否可以使用 PHP 使 Apache 重新加载 SSL 证书,而无需 shell 访问?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40592790/

相关文章:

c# - WCF 休息服务 http 到 https 错误 404

powershell - 使用 .NET API 导入时无法将证书绑定(bind)到 SSL

PHP 变量未填充到表单上的 HTML 日期时间本地字段中

php - 在带有 php 5.3 的 openssl_decrypt 中使用 OPENSSL_RAW_DATA 参数

Php 使用 mysql 查询按类别 ID 获取子类别

bash - 在centos 7上安装solr 6.2.0时无法创建用户

Apache 加载 mod_ssl 但在我的虚拟主机中忽略了 <IfModule mod_ssl.c>

apache - 在 k8s 上安全地运行 apache 容器

ssl - 使用 Kubernetes 服务处理 TLS LetsEncrypt 的良好实践

php - php 中的问题 if 条件