如何批量下载域名证书文件??

2023-03-21 17:03:59 浏览数 (2)

背景

以我个人证书为例,购买后服务商会提供注册机构的证书凭证,证书凭证效果如下。

腾讯云域名管理列表(https://console.cloud.tencent.com/domain/all-domain) 如果管理的域名比较多,又希望批量下载证书时就比较麻烦,因为当前产品功能并未提供批量下载功能。所以今天分享一下,如果来批量下载证书凭证列表。

如何批量下载域名证书文件

介绍一下如何通过脚本批量下载证书文件。 首先打开证书下载页,将证书页的cookies复制到文件中。

复制出来,内容结构大致如下:

代码语言:javascript复制
curl 'https://domain-wss.cloud.tencent.com/domains/api/domain/certificate?domain=djangowang.vip&g_tk=402638928' 
  -H 'authority: domain-wss.cloud.tencent.com' 
  -H 'accept: text/html,application/xhtml xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7' 
  -H 'accept-language: zh-CN,zh;q=0.9,en;q=0.8' 
  -H 'cookie: language=zh; qcloud_uid=5*************6; pgv_pvid=407****938; _gcl_au=1.1.1282719501.1677152303; loginType=qq; wedata_region_id=8; cynosdb_dbType=MYSQL; qcmainCSRFToken=By8GDjv3Jn; qcloud_visitId=cd3fd120280e5ba5c4c4d359cc8ba184; wss_xsrf=e27a5273d577f884fe3a4f572792daed|1678781105; x_host_key_access_https=9f*******************6Ijg4NTE5NzAifQ==","history_login_id":{"name":"$identity_login_id","value":"8851970"},"$device_id":"184ae1be7d6794-0d5c6d486911a1-18525635-2073600-184ae1be7d7a71"}; lastLoginType=qq; uin=o8851970; tinyid=144115211697704307; skey=EvaZhjEpWLsMJEaXN8WW-6kgVTRr-aH-kCd4CuzwaJ0_; intl=1; refreshSession=1; regionId=4; saas_synced_session=8851970|EvaZhjEpWLsMJEaXN8WW-6kgVTRr-aH-kCd4CuzwaJ0_; appid=1254105469; _gat=1; ownerUin=O100001049378G; systemTimeGap=-758; isQcloudUser=true; nick=wds; ci_session=5b515d************d0763cab' 
  -H 'referer: https://console.cloud.tencent.com/' 
  -H 'sec-ch-ua: "Chromium";v="110", "Not A(Brand";v="24", "Google Chrome";v="110"' 
  -H 'sec-ch-ua-mobile: ?0' 
  -H 'sec-ch-ua-platform: "macOS"' 
  -H 'sec-fetch-dest: iframe' 
  -H 'sec-fetch-mode: navigate' 
  -H 'sec-fetch-site: same-site' 
  -H 'sec-fetch-user: ?1' 
  -H 'upgrade-insecure-requests: 1' 
  -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36' 
  --compressed

将以上内容复制到以下脚本中,并命名脚本文件名download_domainname.sh。

代码语言:javascript复制
#!/bin/bash
# filename:download_domainname.sh
while read line
do
domainName=$line
curl -o $domainName.jpg 'https://domain-wss.cloud.tencent.com/domains/api/domain/certificate?domain='$domainName'&g_tk=402638928' 
  -H 'authority: domain-wss.cloud.tencent.com' 
  -H 'accept: text/html,application/xhtml xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7' 
  -H 'accept-language: zh-CN,zh;q=0.9,en;q=0.8' 
  -H 'cookie: language=zh; qcloud_uid=5a8e776; pgv_pvid=4071011938; _gcl_au=1.1.1282719501.1677152303; loginType=qq; wedata_region_id=8; cynosdb_dbType=MYSQL; qcmainCSRFToken=By8GDjv3Jn; qcloud_visitId=cd3fd12c8ba184; wss_xsrf=e28G; systemTimeGap=-758; isQcloudUser=true; nick=wds; ci_session=5b5ab' 
  -H 'referer: https://console.cloud.tencent.com/' 
  -H 'sec-ch-ua: "Chromium";v="110", "Not A(Brand";v="24", "Google Chrome";v="110"' 
  -H 'sec-ch-ua-mobile: ?0' 
  -H 'sec-ch-ua-platform: "macOS"' 
  -H 'sec-fetch-dest: iframe' 
  -H 'sec-fetch-mode: navigate' 
  -H 'sec-fetch-site: same-site' 
  -H 'sec-fetch-user: ?1' 
  -H 'upgrade-insecure-requests: 1' 
  -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36' 
  compressed

done < domainfile

到腾讯云控制台,批量下载证书域名到本地(https://console.cloud.tencent.com/domain/all-domain)。

下载后用Excel打开复制第一列域名到domainfile文件中。

执行一下download_domainname.sh脚本,最终证书就会下载到当前目录中。

0 人点赞