Skip to content

Commit

Permalink
refactor: use stdlib ssl module to convert der cert to pem cert, drop…
Browse files Browse the repository at this point in the history
… pyopenssl dep (#16)
  • Loading branch information
Bodong-Yang authored Oct 24, 2024
1 parent 32dbd2f commit 5aa3ced
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ dependencies = [
"botocore<1.35,==1.34.35",
"pydantic<3,>=2.6",
"pydantic-settings<3,>=2.2.1",
"pyopenssl<25,>=24.1",
"pyyaml<7,>=6.0.1",
"typing-extensions>=4",
]
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ boto3<1.35,>=1.34.35
botocore<1.35,==1.34.35
pydantic<3,>=2.6
pydantic-settings<3,>=2.2.1
pyopenssl<25,>=24.1
pyyaml<7,>=6.0.1
typing-extensions>=4
8 changes: 3 additions & 5 deletions src/otaclient_iot_logging_server/boto3_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@

from __future__ import annotations

import ssl
import subprocess
from pathlib import Path
from typing import Optional

from awsiot_credentialhelper.boto3_session import Boto3SessionProvider
from awsiot_credentialhelper.boto3_session import Pkcs11Config as aws_PKcs11Config
from boto3 import Session
from OpenSSL import crypto

from otaclient_iot_logging_server._utils import parse_pkcs11_uri
from otaclient_iot_logging_server.greengrass_config import (
Expand Down Expand Up @@ -65,10 +65,8 @@ def _convert_to_pem(_data: bytes) -> bytes:
"""Unconditionally convert input cert to PEM format."""
if _data.startswith(b"-----BEGIN CERTIFICATE-----"):
return _data
return crypto.dump_certificate(
crypto.FILETYPE_PEM,
crypto.load_certificate(crypto.FILETYPE_ASN1, _data),
)
# the input _data represents a DER format cert
return ssl.DER_cert_to_PEM_cert(_data).encode()


def _load_certificate(cert_path: str, pkcs11_cfg: Optional[PKCS11Config]) -> bytes:
Expand Down

2 comments on commit 5aa3ced

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
src/otaclient_iot_logging_server
   __init__.py30100% 
   __main__.py18194%49
   _common.py150100% 
   _log_setting.py271062%63, 65–66, 68–69, 73–74, 77–78, 80
   _sd_notify.py33875%42, 52, 57–59, 65–67
   _utils.py53296%73, 137
   _version.py80100% 
   aws_iot_logger.py1005545%65–67, 69–72, 75, 81–87, 90–92, 95–100, 104–107, 111–113, 116–118, 121–126, 139, 145–147, 149–153, 157, 197, 204–207
   boto3_session.py35974%50, 58–59, 61, 76–77, 81, 83, 91
   config_file_monitor.py43686%64–66, 83–85
   configs.py44197%74
   ecu_info.py37197%75
   greengrass_config.py96594%155, 266–269
   log_proxy_server.py441272%52, 77–79, 88–90, 92, 94–95, 100, 106
TOTAL55611080% 

Tests Skipped Failures Errors Time
44 0 💤 0 ❌ 0 🔥 12.333s ⏱️

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
src/otaclient_iot_logging_server
   __init__.py30100% 
   __main__.py18194%49
   _common.py150100% 
   _log_setting.py271062%63, 65–66, 68–69, 73–74, 77–78, 80
   _sd_notify.py33875%42, 52, 57–59, 65–67
   _utils.py54296%73, 137
   _version.py80100% 
   aws_iot_logger.py1015545%65–67, 69–72, 75, 81–87, 90–92, 95–100, 104–107, 111–113, 116–118, 121–126, 139, 145–147, 149–153, 157, 197, 204–207
   boto3_session.py35974%50, 58–59, 61, 76–77, 81, 83, 91
   config_file_monitor.py44686%64–66, 83–85
   configs.py45197%74
   ecu_info.py37197%75
   greengrass_config.py97594%155, 266–269
   log_proxy_server.py441272%52, 77–79, 88–90, 92, 94–95, 100, 106
TOTAL56111080% 

Tests Skipped Failures Errors Time
44 0 💤 0 ❌ 0 🔥 11.851s ⏱️

Please sign in to comment.