如何从 uapi 命令结果中导出 cab crt、key
Posted
技术标签:
【中文标题】如何从 uapi 命令结果中导出 cab crt、key【英文标题】:how to export cab crt , key from uapi command result 【发布时间】:2021-08-16 18:03:36 【问题描述】:使用自定义设置,使用 nginx 作为 web 引擎和 cpanel 需要命令导出 ssl 文件以将其使用到 nginx
cpanel 现在使用由 Comodo 提供支持的 AutoSSL,它免费提供,并且会在任何用户域 ssl 到期时自动更新
在easyApache4
通过这个命令
uapi --user=example SSL fetch_best_for_domain domain='example.com'
我可以从 cpanel 获取所选用户的 ssl
结果
---
apiversion: 3
func: fetch_best_for_domain
module: SSL
result:
data:
cab: "-----BEGIN CERTIFICATE-----\nMIIF8TCCA9mgAwIBAgIRAPAdS+57fKN7PAVmrAWXJFgwDQYJKoZIhvcNAQEMBQAwgYUxCzAJBgNV\nBAYTAkdCMRswGQYDTE1MDUxODAwMDAwMFoXDTI1MDUxNzIzNTk1OVowcjELMAkGA2qXcmH5Qo\nk+kTPUXROjVIHpgNgnDAC1ooh6F4UT+1p1ymkSIAQky5gBWAKrEtiU/3uh4YxIxZHnNJo6h7vB/3\nVk1Qn2cWp8cXSOdtVFd2bpdYW3hkpO1itAA7Bn55uFhfboTWQ7xP2zmqKPDBiQnF++MYRLflsotd\nlfkjWgty92k61leL4en0YL7EUSsRrP5Is3JzyhNQcw0EdsoB4ULC1yHP+Q==\n-----END CERTIFICATE-----\n-----BEGIN CERTIFICATE-----\nMIIFfjCCBGagAwIBAgIQZ970PvF72uJP9ZQGBtLAhDANBgkqhkiG9w0BAQwFADB7MQswCQYDVQQG\nEwJHQjEbMBkGA1UECAwSR3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHDAdTYWxmb3JkMRowGAYD\nVQQKDBFDb21vgrBgEFBQcwAYYYaHR0cDovL29jc3AuY29tb2RvY2EuY29tMA0GCSqG\nSIb3DQEBDAUAA4IBAQB/8lY1sG2VSk50rzribwGLh9Myl+34QNJ3UxHXxxYuxp3mSFa+gKn4vHjS\nyGMXroztFjH6HxjJDsfuSHmfx8m5vMyIFeNoYdGfHUthgddWBGPCCGkm8PDlL9/ACiupBfQCWmqJ\n17SEQpXj6/d2IF412cDNJQgTTHE4joewM4SRmR6R8ayeP6cdYIEsNkFUoOJGBgusG8eZNoxeoQuk\nntlCRiTFxVuBrq2goNyfNriNwh0V+oitgRA5H0TwK5/dEFQMBzSxNtEU/QcCPf9yVasn1iyBQXEp\njUH0UFcafmVgr8vFKHaYrrOoU3aL5iFSa+oh0IQOSU6IU9qSLucdCGbX\n-----END CERTIFICATE-----"
crt: "-----BEGIN CERTIFICATE-----\nMIIGYzCCBUugAwIBAgIQAxTDyiRh8b1+CgQUhztu1TANBgkqhkiG9w0BAQsFADBy\nMQswCQYDVQQGEwJVUzELMAkGA1UECBMCVFgxEDAOBgNVBAcTB0hvdXN0b24xFTAT\nBgNVBAoTDGNQYW5lbCwgSW5jLjEtMCsGASchcwat43LiRWlaxA6\ne+xEjtg0WqTmZ+QulFzZo0c/mfsAkBJyICuoZ/poop2YPou9qgAN6WoemTO6HidoQQ3PlsVyZL\nqBrIW9kege5OPQUTAQIYvesHzdu5HIi00SJsGpnnq+HiFQ9tpcKBDPJiKQIxw6Ec\nYkk/aFbMa8wv577v5Fwo6EUihI7IFMIcoD2+QB7KZrUkl5Skrux7Z5vyyppssSRQ\ne30BKIWZMA1XikFWTKJNB4dN+XrAufc26GzHLmAsi5sTl+UDkqAJ9ubI1LUf9jGY\nwvtL1zy4eCslP4p83fCzB4dc/w7jlsQKaM7BDraSMfnYFDhBhx9QfdjDR8P03ZyG\n4XQJGMLHIA==\n-----END CERTIFICATE-----"
crt_origin: example
domain: example.com
ip: 127.0.0.1
key: "-----BEGIN RSA PRIVATE KEY-----\nMIIEpAIBAAKCAQEAw2OGUfz3smlHcSYH7/ld6WZxk0j0dHK37BfIcVM4zkGcwXUC\nXCiMW3MfqQvA+pZ8AFEtQYLpSfdra/nRvFjvaRzgcbM2ORzUnIXMGreNy4kVpWsQ\nOnv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BtnpZoWLi1F9NECgYATEIv2xeYbPGOi1DiCuCTfihJsaR01e9uEY8Ib\nXDUdJAcKKVfx70kWKg87XheEpd+7ja12HtUG8U+U5WFGmtY/3ohqxebXfQXxk6EM\nr/5GBGnBO2YrvEOdIY6hcvAnYtnJWaCMGovgr+rd1eNfqUB72wcBP4nDLju83EMn\nvz2eyQKBgQDKXUrupETlv26uDRwumo1r+k6WAVRbQFDCc45K9PQT9aMY8bRQRhiN\n3r3jEZcygdDeyGD/x6MrApu9giFR2m8t/XOSvxPelY3WEdADFnkJyom/hUAG/zhp\nSL0byAyOzBv5ny6FiBdg9HrSZ6olYRDHVCFsS8+hQznVkGT84MzUjA==\n-----END RSA PRIVATE KEY-----"
key_origin: example
searched_users:
- example
status: 1
statusmsg: ok
user: example
errors: ~
messages: ~
metadata:
status: 1
warnings: ~
在运行此命令后寻找将 cab 、 crt 和 key 导出为文件的方法
在这个 url 上使用 easyApache 3 的老方法
Old steps
【问题讨论】:
【参考方案1】:我有 11 小时的搜索和查找时间
我构建了该脚本并与 nginx 配合良好
很高兴与您分享
RESULTS=$( uapi --user=example SSL fetch_best_for_domain domain='example.com' )
FIRST=`echo $RESULTS| awk -F \" 'print $2'`
SECOND=`echo $RESULTS| awk -F \" 'print $4'`
THIRD=`echo $RESULTS| awk -F \" 'print $6'`
echo $FIRST | sed 's/\\n/\n/g' > /root/s.example.com.cab
echo $SECOND | sed 's/\\n/\n/g' > /root/s.example.com.crt
echo $THIRD | sed 's/\\n/\n/g' > /root/s.example.com.key
cat /root/s.example.com.crt /root/s.example.com.cab > /root/s.example.com.cert
rm -rf /root/s.example.com.cab /root/s.example.com.crt
【讨论】:
以上是关于如何从 uapi 命令结果中导出 cab crt、key的主要内容,如果未能解决你的问题,请参考以下文章