Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions trustpoint/devices/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
path(
'new-onboarding/',
views.DeviceCreateAddOnboardingTypeView.as_view(),
name=f'{DEVICES_PAGE_DEVICES_SUBCATEGORY}_new_onboarding'
name=f'{DEVICES_PAGE_DEVICES_SUBCATEGORY}_new_onboarding',
),
path(
'opc-ua-gds/create/',
Expand Down Expand Up @@ -100,6 +100,11 @@
devices_help_views.DeviceNoOnboardingCmpSharedSecretHelpView.as_view(),
name=f'{DEVICES_PAGE_DEVICES_SUBCATEGORY}_no_onboarding_cmp_shared_secret_help',
),
path(
'certificate-lifecycle-management/<int:pk>/revoke/cmp/',
devices_help_views.DeviceCmpRevokeHelpView.as_view(),
name=f'{DEVICES_PAGE_DEVICES_SUBCATEGORY}_device_revoke_cmp_help',
),
path(
(
'opc-ua-gds/certificate-lifecycle-management/<int:pk>'
Expand Down Expand Up @@ -444,7 +449,6 @@
views.DeviceBulkDeleteView.as_view(),
name=f'{DEVICES_PAGE_DEVICES_SUBCATEGORY}_device_delete',
),

path(
'zero-touch-credentials/',
ztc_views.OwnerCredentialTableView.as_view(),
Expand Down
85 changes: 85 additions & 0 deletions trustpoint/help_pages/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,91 @@ def get_dynamic_cert_profile_command(
f'-extracertsout full-chain-{cred_number}.pem'
)

@staticmethod
def get_app_cert_domain_revoke_command(
host: str, cred_number: int) -> str:
"""Gets the command for CMP application credential revocation req. using domain credential authentication.

Only for CMP with Domain Credential (onboarding)

Args:
host: The full host name and url path, e.g. https://127.0.0.1/.well-known./cmp/p/...
pk: The primary key of the device in question used as Key Identifier (KID).
shared_secret: The shared secret.
cred_number: The credential number - counter of issued credentials.
sample_request: The sample certificate request in JSON format.

Returns:
The constructed command.
"""
return (
'openssl cmp \\\n'
'-cmd rr \\\n'
f'-server {host} \\\n'
f'-cert domain-credential-certificate-{cred_number}.pem \\\n'
f'-key domain-credential-key-{cred_number}.pem \\\n'
f'-oldcert certificate-{cred_number}.pem \\\n'
f'-revreason 0 \\\n'
f'-trusted domain-credential-full-chain-{cred_number}.pem \\\n'
)

@staticmethod
def get_app_cert_self_revoke_command(
host: str, cred_number: int) -> str:
"""Gets the command for CMP application credential self-revocation request.

Usable for revoking application credentials for both onboarding and no-onboarding,
only if app credential private key is available

Args:
host: The full host name and url path, e.g. https://127.0.0.1/.well-known./cmp/p/...
pk: The primary key of the device in question used as Key Identifier (KID).
shared_secret: The shared secret.
cred_number: The credential number - counter of issued credentials.
sample_request: The sample certificate request in JSON format.

Returns:
The constructed command.
"""
return (
'openssl cmp \\\n'
'-cmd rr \\\n'
f'-server {host} \\\n'
f'-cert certificate-{cred_number}.pem \\\n'
f'-key key-{cred_number}.pem \\\n'
f'-oldcert certificate-{cred_number}.pem \\\n'
f'-revreason 0 \\\n'
f'-trusted domain-credential-full-chain-{cred_number}.pem \\\n'
)

@staticmethod
def get_domain_credential_self_revoke_command(
host: str, cred_number: int) -> str:
"""Gets the command for CMP domain credential self-revocation request.

Only for revoking domain credentials (onboarding)

Args:
host: The full host name and url path, e.g. https://127.0.0.1/.well-known./cmp/p/...
pk: The primary key of the device in question used as Key Identifier (KID).
shared_secret: The shared secret.
cred_number: The credential number - counter of issued credentials.
sample_request: The sample certificate request in JSON format.

Returns:
The constructed command.
"""
return (
'openssl cmp \\\n'
'-cmd rr \\\n'
f'-server {host} \\\n'
f'-cert domain-credential-certificate-{cred_number}.pem \\\n'
f'-key domain-credential-key-{cred_number}.pem \\\n'
f'-oldcert domain-credential-certificate-{cred_number}.pem \\\n'
f'-revreason 0 \\\n'
f'-trusted domain-credential-full-chain-{cred_number}.pem \\\n'
)

@staticmethod
def get_domain_credential_profile_command(host: str, pk: int, shared_secret: str) -> str:
"""Get the domain credential profile command.
Expand Down
Loading
Loading