Certificate generator for GridAppSD and IEEE 2030.5 devices
Project description
GridAppSD Certificate Store
A flexible and secure X.509 certificate generator for IEEE 2030.5 smart grid devices, IoT applications, and general TLS/HTTPS requirements.
Features
- Complete Certificate Generation: Create CAs, device certificates, and self-signed certificates
- IEEE 2030.5 Support: Designed with IEEE 2030.5-2018 standard in mind for smart grid communications
- Multiple Key Types: Support for both RSA and Elliptic Curve cryptography
- Flexible Subject Alternative Names: Create certificates with URIs, DNS names, IP addresses, or email addresses
- TLS 1.2+ Compliance: Generate certificates that meet security requirements for modern TLS
- Certificate Persistence: Easily save and load certificates and private keys
- Web Server Certificates: Specialized method for generating HTTPS server certificates
Installation
# Install from PyPI
pip install gridappsd-certificate-store
# Or with Poetry
poetry add gridappsd-certificate-store
Quick Start
Creating a CA Certificate
from gridappsd_certs.generator import DeviceCertificateGenerator
# Initialize the generator
cert_gen = DeviceCertificateGenerator(key_type='rsa', key_size=2048)
# Create a CA certificate
ca_attrs = {
'common_name': 'GridAppSD Root CA',
'organization': 'GridAppSD',
'country': 'US',
'organizational_unit': 'Security'
}
ca_cert, ca_key = cert_gen.create_ca_certificate(ca_attrs, valid_days=3652)
# Save the certificate and key
cert_gen.save_certificate(ca_cert, 'ca_cert.pem')
cert_gen.save_private_key(ca_key, 'ca_key.pem', password='secure-password')
Creating an IEEE 2030.5 Device Certificate
# Create a device certificate for IEEE 2030.5
device_attrs = {
'common_name': 'Smart Meter 101',
'organization': 'GridAppSD',
'country': 'US',
'organizational_unit': 'Smart Meters',
'serial_number': 'SM101-12345'
}
device_id = '44b0d6d5-aaaa-bbbb-cccc-4d3e17a3175b'
device_cert, device_key = cert_gen.create_device_certificate(
device_attrs,
ca_cert,
ca_key,
device_id=device_id,
san_type='uri' # Default for 2030.5 devices
)
# Save the device certificate and key
cert_gen.save_certificate(device_cert, 'device_cert.pem')
cert_gen.save_private_key(device_key, 'device_key.pem')
Creating a Web Server Certificate
# Create a certificate for a web server
web_attrs = {
'common_name': 'gridappsd.example.org',
'organization': 'GridAppSD',
'country': 'US',
'organizational_unit': 'Web Services'
}
domains = ['gridappsd.example.org', 'www.gridappsd.example.org']
web_cert, web_key = cert_gen.create_web_certificate(
web_attrs,
ca_cert,
ca_key,
domains=domains
)
# Save the web certificate and key
cert_gen.save_certificate(web_cert, 'web_cert.pem')
cert_gen.save_private_key(web_key, 'web_key.pem')
Creating a Self-Signed Device Certificate
# Create a self-signed certificate for an IoT device
iot_attrs = {
'common_name': 'IoT Sensor 042',
'organization': 'GridAppSD',
'country': 'US'
}
from ipaddress import ip_address
iot_cert, iot_key = cert_gen.create_self_signed_device_cert(
iot_attrs,
san_type='ip',
san_values=[ip_address('192.168.1.42')]
)
# Save the IoT device certificate and key
cert_gen.save_certificate(iot_cert, 'iot_cert.pem')
cert_gen.save_private_key(iot_key, 'iot_key.pem')
Certificate Attributes
The following attributes can be included in certificate subject information:
| Dictionary Key | Description |
|---|---|
common_name |
The common name (CN) for the certificate |
country |
Two-letter country code (e.g., 'US') |
state |
State or province name |
locality |
City or locality name |
organization |
Organization name |
organizational_unit |
Department or unit within organization |
email |
Email address |
serial_number |
Serial number (useful for device identification) |
Loading Existing Certificates
# Load a certificate from a file
cert = cert_gen.load_certificate('device_cert.pem')
# Load a private key from a file (with or without password)
key = cert_gen.load_private_key('device_key.pem')
password_protected_key = cert_gen.load_private_key('ca_key.pem', password='secure-password')
IEEE 2030.5 Specifics
The library is designed with IEEE 2030.5-2018 standard in mind, which requires:
- TLS 1.2 with AES-CCM mode of operation
- X.509 certificates for mutual authentication
- Device identification via UUID in Subject Alternative Name
When using this library for IEEE 2030.5 devices, ensure you use the san_type='uri' option with a proper UUID to meet the standard's requirements.
Development
# Clone the repository
git clone https://github.com/yourusername/gridappsd-certificate-store.git
cd gridappsd-certificate-store
# Install dependencies with Poetry
poetry install
# Run tests
poetry run pytest
# Run tests with coverage
poetry run pytest --cov=gridappsd_certs
License
BSD 3-Clause License
Copyright (c) 2023, GridAppSD Contributors All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
-
Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gridappsd_certificate_store-0.2.2.tar.gz.
File metadata
- Download URL: gridappsd_certificate_store-0.2.2.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0d4da162b1e4e113f4c1096e6593b49ffeee6991c049c149c2d2f7df2811a142
|
|
| MD5 |
6f532348858c52ac6486f0494b0111d2
|
|
| BLAKE2b-256 |
22353a42ae14e50fbd45a6653f97b020e593b2309f45803df2a671c1c33ab42e
|
Provenance
The following attestation bundles were made for gridappsd_certificate_store-0.2.2.tar.gz:
Publisher:
publish-to-pypi.yml on GRIDAPPSD/gridappsd-certificate-store
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gridappsd_certificate_store-0.2.2.tar.gz -
Subject digest:
0d4da162b1e4e113f4c1096e6593b49ffeee6991c049c149c2d2f7df2811a142 - Sigstore transparency entry: 213711462
- Sigstore integration time:
-
Permalink:
GRIDAPPSD/gridappsd-certificate-store@a19d4bafb846ba1c6f43c1e2484c7b9adcfa9cfd -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/GRIDAPPSD
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@a19d4bafb846ba1c6f43c1e2484c7b9adcfa9cfd -
Trigger Event:
release
-
Statement type:
File details
Details for the file gridappsd_certificate_store-0.2.2-py3-none-any.whl.
File metadata
- Download URL: gridappsd_certificate_store-0.2.2-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d87af067a21b71163fe4d4ce3ff1edd5ae5214e161dd8beac32a0e7047d5cecb
|
|
| MD5 |
daa467869688112ada20f291b86119de
|
|
| BLAKE2b-256 |
f44a311eebafae7c109f45a24ab30df4ed7aca3cf49388e0ad97140e2930f62c
|
Provenance
The following attestation bundles were made for gridappsd_certificate_store-0.2.2-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on GRIDAPPSD/gridappsd-certificate-store
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gridappsd_certificate_store-0.2.2-py3-none-any.whl -
Subject digest:
d87af067a21b71163fe4d4ce3ff1edd5ae5214e161dd8beac32a0e7047d5cecb - Sigstore transparency entry: 213711464
- Sigstore integration time:
-
Permalink:
GRIDAPPSD/gridappsd-certificate-store@a19d4bafb846ba1c6f43c1e2484c7b9adcfa9cfd -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/GRIDAPPSD
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@a19d4bafb846ba1c6f43c1e2484c7b9adcfa9cfd -
Trigger Event:
release
-
Statement type: