Table of Contents

Class SecomClientIdentity

Namespace
EncDotNet.S100.Collections.Secom
Assembly
EncDotNet.S100.Collections.dll

An MCP identity for SECOM requests (issue #832): a client certificate with its private key, presented by SecomServerTrust's handlers when a SECOM service asks for one (mutual TLS).

public sealed class SecomClientIdentity : IDisposable
Inheritance
SecomClientIdentity
Implements
Inherited Members

Remarks

Identities are issued by an MCP Identity Registry to an organisation's devices and services; their subject carries the MRN (as UID). This library only holds an identity in memory: loading it from a key store and persisting it is the host's concern.

Properties

Anchor

The trust anchor the certificate chains to (e.g. "MCP MCC"), or null for none.

public string? Anchor { get; }

Property Value

string

CallSign

The vessel's call sign, when the certificate carries the MCP attribute.

public string? CallSign { get; }

Property Value

string

Certificate

The certificate, with its private key.

public X509Certificate2 Certificate { get; }

Property Value

X509Certificate2

DisplayName

The MRN when there is one, otherwise the subject: how the identity is named in messages.

public string DisplayName { get; }

Property Value

string

FlagState

The vessel's flag state, when the certificate carries the MCP attribute.

public string? FlagState { get; }

Property Value

string

ImoNumber

The vessel's IMO number, when the certificate carries the MCP attribute.

public string? ImoNumber { get; }

Property Value

string

Issuer

The issuer's common name, e.g. "MCP Identity Registry".

public string Issuer { get; }

Property Value

string

Mmsi

The vessel's MMSI, when the certificate carries the MCP attribute.

public string? Mmsi { get; }

Property Value

string

Mrn

The MRN the certificate was issued to (its subject UID), when it has one.

public string? Mrn { get; }

Property Value

string

NotAfter

When the certificate expires.

public DateTimeOffset NotAfter { get; }

Property Value

DateTimeOffset

NotBefore

When the certificate becomes valid.

public DateTimeOffset NotBefore { get; }

Property Value

DateTimeOffset

Subject

The certificate's subject common name.

public string Subject { get; }

Property Value

string

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

FromCertificate(X509Certificate2, SecomTrustAnchors?)

Wraps a certificate that already holds its private key.

public static SecomClientIdentity FromCertificate(X509Certificate2 certificate, SecomTrustAnchors? anchors = null)

Parameters

certificate X509Certificate2

The certificate; the identity takes ownership of it.

anchors SecomTrustAnchors

The anchors to report Anchor against; by default BuiltIn.

Returns

SecomClientIdentity

Exceptions

InvalidDataException

The certificate has no private key.

IsValidAt(DateTimeOffset)

True when at lies within the certificate's validity period.

public bool IsValidAt(DateTimeOffset at)

Parameters

at DateTimeOffset

Returns

bool

Load(string, string?, SecomTrustAnchors?, X509KeyStorageFlags)

Loads an identity from a PKCS#12 file (.p12, .pfx) or a PEM file holding the certificate and its private key (optionally encrypted), as the MCP Management Portal issues them.

public static SecomClientIdentity Load(string path, string? password = null, SecomTrustAnchors? anchors = null, X509KeyStorageFlags keyStorageFlags = X509KeyStorageFlags.DefaultKeySet)

Parameters

path string

The file.

password string

The PKCS#12 or encrypted-key password, if any.

anchors SecomTrustAnchors

The anchors to report Anchor against; by default BuiltIn.

keyStorageFlags X509KeyStorageFlags

How the private key is held, e.g. Exportable or PersistKeySet for a host that adds the identity to a platform key store; by default the platform's default.

Returns

SecomClientIdentity

Exceptions

FileNotFoundException

The file does not exist.

InvalidDataException

The file holds no certificate with a private key, or the password is wrong.