-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
66 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
@File : cert_service.py | ||
@Date : 2024-08-05 | ||
""" | ||
|
||
from domain_admin.utils import domain_util | ||
from domain_admin.utils.cert_util import cert_openssl_v2, cert_common | ||
|
||
|
||
def get_cert_information(domain): | ||
""" | ||
获取域名证书信息 | ||
:return: | ||
""" | ||
|
||
# 解析域名 | ||
resolve_domain = domain_util.parse_domain(domain) | ||
|
||
cert = cert_openssl_v2.get_ssl_cert(resolve_domain) | ||
parsed_cert = cert_common.parse_cert(cert) | ||
cert_pem = cert_common.dump_certificate_to_pem(cert) | ||
cert_text = cert_common.dump_certificate_to_text(cert) | ||
|
||
return { | ||
'resolve_domain': resolve_domain, | ||
'parsed_cert': parsed_cert.to_dict() if parsed_cert else parsed_cert, | ||
'cert_pem': cert_pem, | ||
'cert_text': cert_text, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
@File : cert_service_test.py | ||
@Date : 2024-08-05 | ||
""" | ||
import unittest | ||
|
||
from domain_admin.service import cert_service | ||
from domain_admin.utils import json_util | ||
from domain_admin.utils.cert_util import cert_common, cert_openssl_v2 | ||
|
||
|
||
class CertServiceTest(unittest.TestCase): | ||
def test_get_cert_information(self): | ||
domain = 'https://www.boc.cn/' | ||
ret = cert_service.get_cert_information(domain=domain) | ||
print(json_util.json_dump(ret)) | ||
|
||
def test_is_extended_validation(self): | ||
cert = cert_openssl_v2.get_ssl_cert('www.boc.cn') | ||
# ret = cert_common.is_extended_validation(cert) | ||
# print(ret) |