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: 8 additions & 0 deletions trustpoint/devices/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,14 @@
'_certificate_lifecycle_management_issue_domain_credential_est_username_password'
),
),
path(
'certificate-lifecycle-management/<int:pk>/simplereenroll/est/',
devices_help_views.EstSimpleReEnrollHelpView.as_view(),
name=(
f'{DEVICES_PAGE_DEVICES_SUBCATEGORY}'
'_certificate_lifecycle_management_issue_domain_credential_est_username_password'
),
),
path(
'opc-ua-gds/certificate-lifecycle-management/<int:pk>/onboarding/issue-domain-credential/est-username-password/',
devices_help_views.OpcUaGdsOnboardingDomainCredentialEstUsernamePasswordHelpView.as_view(),
Expand Down
93 changes: 93 additions & 0 deletions trustpoint/help_pages/devices_help_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,92 @@ def build_sections(self, help_context: HelpContext) -> tuple[list[HelpSection],
]
return sections, _non_lazy('Help - Issue a Domain Credential using EST with username and password')

class EstSimpleReEnrollStrategy(HelpPageStrategy):
"""Strategy for building the onboarding est username and password help page."""

@override
def build_sections(self, help_context: HelpContext) -> tuple[list[HelpSection], str]:
device = help_context.get_device_or_http_404()
onboarding_config = getattr(device, 'onboarding_config', None)
if not onboarding_config:
raise Http404(_('Onboarding is not configured for this device.'))
est_password = onboarding_config.est_password
operation = 'simpleenroll'
base = help_context.host_est_path


summary = HelpSection(
_non_lazy('Summary'),
[
HelpRow(
_non_lazy('Certificate Request URL'),
f'{base}/{operation}',
ValueRenderType.CODE,
),
HelpRow(
_non_lazy('Required Public Key Type'),
str(help_context.domain.public_key_info),
ValueRenderType.CODE,
),
HelpRow(
key=('EST-Username'),
value=device.common_name,
value_render_type=ValueRenderType.CODE,
),
HelpRow(
key=('EST-Password'),
value=est_password,
value_render_type=ValueRenderType.CODE,
),
],
)

openssl_req_cmd = EstUsernamePasswordCommandBuilder.get_domain_credential_profile_command()

openssl_req_cmd_row = HelpRow(
key=_non_lazy('OpenSSL Command'),
value=openssl_req_cmd,
value_render_type=ValueRenderType.CODE,
)

enroll_cmd = EstUsernamePasswordCommandBuilder.get_curl_enroll_domain_credential_command(
est_username=device.common_name,
est_password=est_password,
host=f'{base}/{help_context.domain.get_domain_credential_profile_name()}/simpleenroll/',
)

enroll_cmd_row = HelpRow(
key=_non_lazy('ReEnroll domain credential with curl'),
value=enroll_cmd,
value_render_type=ValueRenderType.CODE,
)

openssl_req_cmd_section = HelpSection(
heading=_non_lazy('Generate PKCS#10 CSR for the domain credential'),
rows=[openssl_req_cmd_row, enroll_cmd_row],
hidden=False,
css_id='domain_credential',
)

der_to_pem_convertion_section = HelpSection(
heading=_non_lazy('Convert the certificate from PKCS#7 to PEM format (Optional)'),
rows=[
HelpRow(
key=_non_lazy('OpenSSL Command'),
value=EstUsernamePasswordCommandBuilder.get_domain_credential_conversion_p7_pem_command(),
value_render_type=ValueRenderType.CODE,
)
],
)

sections = [
summary,
build_tls_trust_store_section(),
openssl_req_cmd_section,
der_to_pem_convertion_section,
]
return sections, _non_lazy('Help - Issue a Domain Credential using EST with username and password')


class DeviceOnboardingDomainCredentialEstUsernamePasswordHelpView(BaseHelpView):
"""Help view for the case of onboarding using EST username & password for generic device abstractions."""
Expand All @@ -567,6 +653,13 @@ class DeviceOnboardingDomainCredentialEstUsernamePasswordHelpView(BaseHelpView):
strategy = OnboardingDomainCredentialEstUsernamePasswordStrategy()


class EstSimpleReEnrollHelpView(BaseHelpView):
"""Help view for the case of onboarding using EST username & password for generic device abstractions."""

page_name = DEVICES_PAGE_DEVICES_SUBCATEGORY
strategy = EstSimpleReEnrollStrategy()


class OpcUaGdsOnboardingDomainCredentialEstUsernamePasswordHelpView(BaseHelpView):
"""Help view for the case of onboarding using EST username & password for OPC-UA GDS abstractions."""

Expand Down
Loading