# Support for Elliptic Curve Cryptography (ECC) Certificates in Server and Client Applications Server and client applications support encrypted communication with RSA and elliptic curve cryptography (ECC) certificates. This guide explains how to configure both certificate types. ## Contents - [Previous client and server configuration (RSA only)](#previous-client-and-server-application-configuration-supports-only-rsa-certificates) - [Previous server configuration (RSA only)](#previous-server-application-configuration-supports-only-rsa-certificates) - [New client and server configuration (RSA and ECC)](#new-client-and-server-application-configuration-support-both-rsa-and-ecc-certificates) - [New server configuration for ECC](#new-server-application-configuration-related-to-ecc-certificates) - [Old and new configuration compatibility](#old-client-and-server-application-configuration-format-vs-new-client-and-server-application-configuration-format) - [Configure GDS for ECC](#configure-gds-for-use-with-ecc-certificates) - [Known limitations](#known-limitations) The [previous configuration](#previous-client-and-server-application-configuration-supports-only-rsa-certificates) supports RSA certificates. The [new configuration](#new-client-and-server-application-configuration-support-both-rsa-and-ecc-certificates) supports both RSA and ECC certificates. The guide also describes compatibility and ECC limitations. ## Previous Client and Server application configuration supports only RSA certificates Up to now, the configuration supported encrypted communication using only the RSA encryption algorithm. That means that the server and client certificates were RSA certificates and there was just one RSA certificate per application needed to be configured. The XML tag which contained the RSA certificate to be configured was ``. This tag is still used for the RSA certificate configuration in backward compatibility mode as further described below: ```xml Directory %LocalApplicationData%/OPC Foundation/pki/own CN=Quickstart Reference Server, C=US, S=Arizona, O=OPC Foundation, DC=localhost .... ``` ## Previous Server application configuration supports only RSA certificates For Server applications the configuration of the RSA certificate involves also specifying the SecurityPolicies to be supported by the server: ```xml SignAndEncrypt_3 http://opcfoundation.org/UA/SecurityPolicy#Basic256Sha256 None_1 http://opcfoundation.org/UA/SecurityPolicy#None Sign_2 SignAndEncrypt_3 .... ``` ## New Client and Server application configuration support both RSA and ECC certificates With the newly introduced support for ECC certificates, the configuration of the server application has been extended to support both RSA and ECC certificates. The XML tag under which both the RSA and ECC certificates are configured is ``. The `` tag is still used for the RSA certificate configuration in backward compatibility mode, meaning that old server configurations are still supported, but they cannot simultaneously coexist. The new configuration of the server application is described below: ```xml Directory %LocalApplicationData%/OPC Foundation/pki/own CN=Quickstart Reference Server, C=US, S=Arizona, O=OPC Foundation, DC=localhost RsaSha256 Directory %LocalApplicationData%/OPC Foundation/pki/own CN=Quickstart Reference Server, C=US, S=Arizona, O=OPC Foundation, DC=localhost NistP256 Directory %LocalApplicationData%/OPC Foundation/pki/own CN=Quickstart Reference Server, C=US, S=Arizona, O=OPC Foundation, DC=localhost NistP384 Directory %LocalApplicationData%/OPC Foundation/pki/own CN=Quickstart Reference Server, C=US, S=Arizona, O=OPC Foundation, DC=localhost BrainpoolP256r1 Directory %LocalApplicationData%/OPC Foundation/pki/own CN=Quickstart Reference Server, C=US, S=Arizona, O=OPC Foundation, DC=localhost BrainpoolP384r1 .... ``` This layout of the configuration file allows the server to support both RSA and ECC certificates and allows the server to generate certificates of different types. The `` tag is used to specify the type of the certificate. The supported types are: - `RsaSha256` for RSA certificates - `NistP256` for ECC certificates with NIST P256 curve - `NistP384` for ECC certificates with NIST P384 curve - `BrainpoolP256r1` for ECC certificates with Brainpool P256r1 curve - `BrainpoolP384r1` for ECC certificates with Brainpool P384r1 curve Additionally, this layout enables the user to select a specific `` for each certificate. This is useful when the user wants to generate certificates with different ``s. ## New Server application configuration related to ECC certificates The Server applications can configure the supported SecurityPolicies in the same way as before, but now the SecurityPolicies can be configured for each ECC specific SecurityPolicyUri which is to be supported by the server: ```xml SignAndEncrypt_3 http://opcfoundation.org/UA/SecurityPolicy#Basic256Sha256 Sign_2 SignAndEncrypt_3 Sign_2 http://opcfoundation.org/UA/SecurityPolicy#ECC_nistP256 Sign_2 http://opcfoundation.org/UA/SecurityPolicy#ECC_nistP384 Sign_2 http://opcfoundation.org/UA/SecurityPolicy#ECC_brainpoolP256r1 Sign_2 http://opcfoundation.org/UA/SecurityPolicy#ECC_brainpoolP384r1 SignAndEncrypt_3 http://opcfoundation.org/UA/SecurityPolicy#ECC_nistP256 SignAndEncrypt_3 http://opcfoundation.org/UA/SecurityPolicy#ECC_nistP384 SignAndEncrypt_3 http://opcfoundation.org/UA/SecurityPolicy#ECC_brainpoolP256r1 SignAndEncrypt_3 http://opcfoundation.org/UA/SecurityPolicy#ECC_brainpoolP384r1 .... ``` With the introduction of ECC certificates, the `` section of the configuration file has been extended to support ECC specific SecurityPolicies. The ECC specific SecurityPolicies are the following: - `http://opcfoundation.org/UA/SecurityPolicy#ECC_nistP256` - `http://opcfoundation.org/UA/SecurityPolicy#ECC_nistP384` - `http://opcfoundation.org/UA/SecurityPolicy#ECC_brainpoolP256r1` - `http://opcfoundation.org/UA/SecurityPolicy#ECC_brainpoolP384r1` For every ECC-specific policy in ``, the server must have a corresponding ECC certificate in ``. Its `CertificateTypeString` must match the policy's curve. If a corresponding certificate is missing, the server cannot start. The server encrypts each `UserIdentityToken` with the certificate selected by the active security policy or by the `` in its ``. To explicitly list the policies supported for user identity tokens, configure them in ``. They must also appear in ``. The following example shows how the server can specify the supported ``s for the UserIdentityTokens: ```xml Anonymous_0 UserName_1 UserName_1 http://opcfoundation.org/UA/SecurityPolicy#Basic256Sha256 ``` You can omit `` from ``. In that case, the server uses the active security policy to encrypt the `UserIdentityToken`. Therefore, each policy listed in `` must also appear in ``. If `` names a policy that `` does not include, the configuration is invalid. ## "Old" Client and Server application configuration format VS "New" Client and Server application configuration format Applications using the old configuration continue to use RSA certificates configured with ``. The server must not list ECC policies in ``. These applications cannot communicate with peers that require ECC certificates. Applications using the new configuration can support both RSA and ECC certificates. Configure both certificate types with ``, then list the supported policies in ``, including any ECC policies. Use `` to configure the policies used to encrypt user identity tokens. These policies must also appear in ``. Do not combine the old and new configuration formats. A configuration file cannot contain both `` and ``. ## Configure GDS for use with ECC Certificates To use ECC certificates with the Global Discovery Server (GDS), update its configuration as shown below. ```xml Default RsaSha256ApplicationCertificateType ``` Replace the `` node of the Default CertificateGroupConfiguration with the `` node. This allows the Certificate Group to have multiple CA Certificates for the different Certificate types. ```xml Default RsaSha256ApplicationCertificateType EccNistP256ApplicationCertificateType EccNistP384ApplicationCertificateType ``` The old Configuration format is still supported but only supports either RSA or ECC Certificates for a single CertificateGroup. The GDS checks on startup if a valid configuration was supplied. ## Known Limitations Not all curves are supported by all OS platforms and not all .NET implementations offer cryptographic API support for all curve types. **On .NET Framework 4.8 the ECDH agreement and the AEAD ciphers run in BouncyCastle.** OPC UA Part 6 feeds the raw ECDH shared secret into HKDF. .NET Framework only offers `ECDiffieHellman.DeriveKeyMaterial`, which hashes the secret first, so the .NET Framework 4.8 build computes the raw agreement with the managed `BouncyCastle.Cryptography` implementation (`ECDHBasicAgreement`), which `Opc.Ua.Security.Certificates` already references on that target. The ephemeral keys, ECDSA signatures and HKDF stay on the platform (CNG) providers; only the agreement step is managed code. The AES-GCM and ChaCha20-Poly1305 variants of the ECC policies (`ECC_*_AesGcm`, `ECC_*_ChaChaPoly`) and `RSA_DH_AesGcm` / `RSA_DH_ChaChaPoly` need authenticated ciphers that .NET Framework does not have, so on that target the stack runs AES-GCM (`GcmBlockCipher` over `AesEngine`) and ChaCha20-Poly1305 in BouncyCastle as well, also for the encrypted ECC user tokens. Deployments bound to FIPS-validated or other certified cryptographic modules should note that these steps are not performed by a validated module on .NET Framework, so `CryptoCompliancePolicy.FipsOnly` withholds the ECC and AEAD policies there, and that the managed AES is neither hardware accelerated nor hardened against cache-timing side channels like the CNG implementation; use the .NET 8+ build, or an RSA policy, where that matters. The .NET 8+ builds use `ECDiffieHellman.DeriveRawSecretAgreement`, `AesGcm` and `ChaCha20Poly1305` from the BCL and do not load BouncyCastle for them. All ECC policies (`ECC_nistP256`, `ECC_nistP384`, `ECC_brainpoolP256r1`, `ECC_brainpoolP384r1` and their `_AesGcm` / `_ChaChaPoly` variants) are available on every target, subject to the OS supporting the curve. ECC certificate parsing and signing remain subject to OS curve support. The supported ECC curve types are the following: - `NistP256` for ECC certificates with NIST P256 curve - `NistP384` for ECC certificates with NIST P384 curve - `BrainpoolP256r1` for ECC certificates with Brainpool P256r1 curve - `BrainpoolP384r1` for ECC certificates with Brainpool P384r1 curve