Skip to main content

A SDK package of TrustOcean Limited SSL API

Project description

TRUSTOCEAN SSL SDK

由TrustOcean Limited专门为Python用户开发的TrustOcean API SDK, 用于对接数字证书接口,支持数字证书申请、吊销、验证、续期等操作。

环智中诚 WIKI页面 API说明文档 环智中诚官网 在线客服

安装步骤

1.确保Python版本正确:

  • Python >= 3.6

2.安装依赖库

pip install requests
pip install pyOpenSSL
pip install pem

3.安装此SDK

pip install trustocean_sdk

开始使用

在开始使用此API SDK库之前,请确保您已经拥有了环智中诚的账户,且保证您的账户已经具备了API服务的访问权限。

获取API登陆信息并添加白名单

  • API USERNAME就是您的环智中诚账户邮箱地址/Tier2 API的用户名
  • API PASSWORD/Token密码,如果您已经生成过,请继续使用之前生成的。如果还没有生成,可以通过 访问此页面创建 ,特别注意,当您生成了新的API-Token之后,之前的API-Token将会失效。
  • 同时需要将您用于请求API的电脑/服务器的公网IPv4地址添加到 此页面的API白名单 一栏,才可确保能正常和接口交互。

在您的项目代码中使用此SDK

引入SDK库中的API客户端到代码

from trustocean_sdk import client as TrustOceanClient

创建API客户端实例

api_username = '你的环智中诚账户邮箱地址'
api_token = '你在环智中诚API页面创建的API-Token'

apiClient = TrustOceanClient.APIClient(api_username, api_token)

检查是否可以正常访问API服务

result = apiClient.check_service_status()
if result['status'] == 'success':
    print('connected')
else:
    print('connection error')
    print(result)
生成用于创建SSL订单的CSR代码和KEY私钥

此SDK提供了一系列工具来帮助您更加轻松的创建SSL证书订单,在开始使用这些工具之前,您需要先导入工具库到您的代码中

from trustocean_sdk import utils as TrustOceanUtils

创建RSA签名的CSR代码和KEY私钥,用于申请常用的RSA2048位加密的SSL证书

x509Utils = TrustOceanUtils.X509Utils()
new_key_pair = x509Utils.generate_csr(TrustOceanUtils.X509Utils.SIGN_TYPE_RSA, 'trustocean.com')
print(key_pair['csr_code']) # 文本格式的CSR代码内容
print(key_pair['key_code']) # 文本格式的私钥KEY代码内容

创建ECC签名的CSR代码和KEY私钥,用于申请更高安全系数的ECC加密的SSL证书

x509Utils = TrustOceanUtils.X509Utils()
new_key_pair = x509Utils.generate_csr(TrustOceanUtils.X509Utils.SIGN_TYPE_ECC, 'trustocean.com')
print(new_key_pair['csr_code']) # 文本格式的CSR代码内容
print(new_key_pair['key_code']) # 文本格式的私钥KEY代码内容
获取API账户可订购的产品信息

此接口主要用于获取产品信息,产品信息中的多个信息将用于后续创建证书订单的接口,因此您需要将您的产品信息缓存在本地以备用,或根据自己的业务逻辑进行存储。

products = apiClient.get_product_list()
print(products['products'])

响应中的products值为pid->[productinfo]格式的参数,对应每款产品信息,产品信息中最主要的参数包括

pid: 产品的pid,用于订购下单
name: 产品的名称
class: 产品的验证类型 DV/OV/EV
multidomain: 是否支持保护多条域名 off/on
wildcard: 是否支持保护通配符域名 off/on
ipv4: 是否支持保护公网IPv4地址 off/on
brand: 产品的品牌
chineseName: 产品的中文名称备注
periods: 产品支持的订购周期,下单时可以对照 trustocean_sdk.client.ProductPeriodHelper 中定义的常量进行传入

更多使用方法和说明,请查看此项目的WIKI页面,>>点此进入WIKI页面

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

trustocean-sdk-1.0.1.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

trustocean_sdk-1.0.1-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file trustocean-sdk-1.0.1.tar.gz.

File metadata

  • Download URL: trustocean-sdk-1.0.1.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.55.2 CPython/3.9.0

File hashes

Hashes for trustocean-sdk-1.0.1.tar.gz
Algorithm Hash digest
SHA256 3323dcebb3254c096b91c9af40770f99dff29b56a2c2eb20bc0e13c30383aa9a
MD5 55e72363cae36b17b63a6db2e5b0c2a4
BLAKE2b-256 01afa22774c9ba6b120c262baae0773bddfe8e47caf4ca12fd4e09eac6239664

See more details on using hashes here.

File details

Details for the file trustocean_sdk-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: trustocean_sdk-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.55.2 CPython/3.9.0

File hashes

Hashes for trustocean_sdk-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e5c169d124c0fb53703554927b2c935b1ba844658819638711305368cc3c91db
MD5 edd0e3bcc3bd9b023513e658d488872a
BLAKE2b-256 1b86ca87b3c03f9a6d68514e5dc856a0601b29373b82deb8b91a66155bd38d1f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page