tencent cloud

SSL Certificates

Release Notes
Announcements
Notice on price adjustment of DigiCert and its affiliated brands'SSL certificates​
Price Change to DigiCert SSL Certificates
TrustAsia Root Certificate Update
Domain Validation Policy Update
SSL Certificate Service Console
Multi-Year SSL Certificate and Automatic Review
Notice on Stopping the Issuance of 2-Year SSL Certificates by CAs Starting from September 1, 2020
Announcement on Stop Using the Symantec SSL Certificate Name After 30 April 2020
Notice on Certificate Revocation Due to Private Key Compromises
Notice on Application Limits for DV SSL Certificates
Notice on Adjustment of Free SSL Certificates Policy
Let's Encrypt Root Certificate Expired on September 30, 2021
Product Introduction
Overview
Introduction to Tencent Cloud SSL Certificates
Strengths
Advantages of HTTPS
Browser Compatibility Test Report
Multi-Year SSL Certificate and Automatic Review Overview
SSL Certificate Security
Purchase Guide
Pricing
SSL Certificate Purchase Process
SSL Certificate Selection
Paid SSL Certificates Renewal
SSL Certificate Renewal Process
SSL Certificate Refund Process
Getting Started
Certificate Application
Information Submission Process for Paid SSL Certificates
Domain Ownership Validation
Domain Validation Method Selection
Automatic DNS Addition
DNS Validation
File Validation
Automatic DNS Validation
Automatic File Validation
Validation Result Troubleshooting Guide
Operation Guide
Domain Ownership Verification
Uploading Certificates
Secured Seal
CSR Management
Certificate Installation
Installing an SSL Certificate on a Tencent Cloud Service
Installation of International Standard Certificates
Selecting an Installation Type for an SSL Certificate
Certificate Management
Instructions on SSL Certificate Auto-Renewal
Certificate Hosting
Uploading (Hosting) an SSL Certificate
Reminding Reviewers to Review an SSL Certificate Application
Revoking an SSL Certificate
Deleting an SSL Certificate
Reissuing an SSL Certificate
Ignoring SSL Certificate Notifications
Customizing SSL Certificate Expiration Notifications
API Documentation
History
Introduction
API Category
Making API Requests
Certificate APIs
Certificate Renewal (Certificate ID Unchanged) APIs
CSR APIs
Data Types
Error Codes
Use Cases
Automatic Solution for Implementing and Issuing Multi-Year Certificates and Binding Resources
Apple ATS Server Configuration
Quickly Applying for a Free SSL Certificate via DNSPod
Enabling Tencent Cloud DDNS and Installing Free Certificates for Synology NAS
Batch Applying for and Downloading Free Certificates Using Python-based API Calls
Profile Management
Adding Organization Profile
Adding Administrator
Adding Domain
Troubleshooting
Domain Validation Failed
Domain Security Review Failed
Website Inaccessible After an SSL Certificate is Deployed
404 Error After the SSL Certificate is Deployed on IIS
“Your Connection is Not Secure” is Displayed After the SSL Certificate is Installed
Message Indicating Parsing Failure Is Displayed When a Certificate Is Uploaded
Automatic DNS Validation Failed for a Domain Hosted with www.west.cn
Host Name Field Cannot Be Edited in IIS Manager When Type Is Set to https
Message Indicating Intermediate Certificates Missing in Chain Is Displayed When a Free SSL Certificate Is Deployed on IIS
FAQs
SSL Certificate Selection
SSL Certificate Application
SSL Certificate Management
SSL Certificate Installation
SSL Certificate Region
SSL Certificate Review
SSL Certificate Taking Effect
SSL Certificate Billing and Purchase
SSL Certificate Validity Period
Related Agreement
SSL Service Level Agreement
Contact Us
Glossary
DocumentationSSL CertificatesUse CasesBatch Applying for and Downloading Free Certificates Using Python-based API Calls

Batch Applying for and Downloading Free Certificates Using Python-based API Calls

PDF
Focus Mode
Font Size
Last updated: 2024-03-06 17:49:08

Overview

This document describes how to batch apply for and download certificates using Tencent Cloud APIs.

Preparations

Create a sub-account and authorize it with all permissions associated with cloud APIs and SSL certificates.
Install the latest version of Python. Download the package via here if necessary.
Install the latest version of PyCharm. Download it via here if necessary.
Note:
To keep your account and cloud assets under it secure, properly keep and regularly update SecretId and SecretKey.
Create a sub-account as instructed in Creating and Authorizing Sub-account.

Directions

1. Open the command prompt window and view the Python script with the following command:
python -V
2. View installed third-party modules for Python with the following command:
pip list

Note:
For example, if requests is missing, install it with pip install requests.
3. Use pip to install Tencent Cloud Python SDK with the following command:
pip install -i https://mirrors.tencent.com/pypi/simple/ --upgrade tencentcloud-sdk-python
4. Download the latest code from Github repository or Gitee repository and decompress it.
5. Open PyCharm, import the latest code file, create a new .py file under the tencentcloud-sdk-python/tencentcloud/ssl directory, such as apply.py, add the following code in the file and run.
import json,base64
from time import time,sleep
from tencentcloud.common import credential
from tencentcloud.common.profile.client_profile import ClientProfile
from tencentcloud.common.profile.http_profile import HttpProfile
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.ssl.v20191205 import ssl_client, models

start = time()
#SecretId: Your API SecretID; SecretKey: Your API SecretKey.
cred = credential.Credential("SecretId", "SecretKey")
httpProfile = HttpProfile()
httpProfile.endpoint = "ssl.tencentcloudapi.com"
clientProfile = ClientProfile()
clientProfile.httpProfile = httpProfile
domain_name = []
while True:
domain = input('the domain for which a certificate is applied')#Enter the domain to be bound with the certificate you are applying for; if you don’t want to continue, press Enter.
if domain == '':
break
else:
domain_name.append(domain)

for i in range(len(domain_name)):
client = ssl_client.SslClient(cred, "", clientProfile)
try:

req = models.ApplyCertificateRequest()
params = {
"DvAuthMethod": "DNS_AUTO",
"DomainName": domain_name[i]
}
req.from_json_string(json.dumps(params))

resp = client.ApplyCertificate(req)
response = json.loads(resp.to_json_string())
print('domain: {0}material submitted, auto-verification in 5s'.format(domain_name[i]))
certid = response['CertificateId']
sleep(5)
try:
req1 = models.CompleteCertificateRequest()
params1 = {
"CertificateId": certid
}
req1.from_json_string(json.dumps(params1))

resp1 = client.CompleteCertificate(req1)
response1 = json.loads(resp1.to_json_string())
print('doman: {0}verified successfully. Prepare to download the certificate'.format(domain_name[i]))
try:
req2 = models.DownloadCertificateRequest()
params2 = {
"CertificateId": certid
}
req2.from_json_string(json.dumps(params2))

resp2 = client.DownloadCertificate(req2)
response2 = json.loads(resp2.to_json_string())
# print(response2['Content'])
content = response2['Content']
with open("{0}.zip".format(domain_name[i]), "wb") as f:

f.write(base64.b64decode(content))
f.close()
except TencentCloudSDKException as err:
print(err)
except TencentCloudSDKException as err:
print(err)
except TencentCloudSDKException as err:
print(err)
end = time()
print('This code execution takes', round(end - start, 2), 's')

Result display

1. Apply for certificates in batches.
2. Download certificates.


Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback