# OpcCertificateRequestedEventArgs Members

> Reference: Provides the event data for the CertificateRequested event.

<dl class="api-definition">
<dt>Type</dt>
<dd><a href="./">OpcCertificateRequestedEventArgs</a></dd>
<dt>Namespace</dt>
<dd><a href="../namespaces/opc.uafx">Opc.UaFx</a></dd>
<dt>Assembly</dt>
<dd>Opc.UaFx.Advanced.dll</dd>
<dt>Package</dt>
<dd>Opc.UaFx.Advanced v2.59.0</dd>
<dt>Also in</dt>
<dd>Opc.UaFx.Client</dd>
</dl>

Inherits members from [EventArgs](https://learn.microsoft.com/dotnet/api/system.eventargs).

## Constructors

### OpcCertificateRequestedEventArgs

Initializes a new instance of the [OpcCertificateRequestedEventArgs](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccertificaterequestedeventargs/) class using the event data specified.

<div class="api-signature" data-lang="csharp">

```csharp
public OpcCertificateRequestedEventArgs(
    X509Certificate2 originalCertificate,
    OpcCertificateValidationResult reason,
    bool autoCreateCertificate)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Sub New(
    originalCertificate As X509Certificate2,
    reason As OpcCertificateValidationResult,
    autoCreateCertificate As Boolean)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `originalCertificate` | [X509Certificate2](https://learn.microsoft.com/dotnet/api/system.security.cryptography.x509certificates.x509certificate2) | The original [X509Certificate2](https://learn.microsoft.com/dotnet/api/system.security.cryptography.x509certificates.x509certificate2) information determined, evaluated and not used upon `reason`. |
| `reason` | [OpcCertificateValidationResult](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccertificatevalidationresult/) | One of the members defined by the [OpcCertificateValidationResult](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccertificatevalidationresult/) enumeration indicating the reson why the `originalCertificate` is not used. |
| `autoCreateCertificate` | [Boolean](https://learn.microsoft.com/dotnet/api/system.boolean) | A value indicating whether a different certificate is created automatically if [AlternativeCertificate](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccertificaterequestedeventargs/members#alternativecertificate) is not defined. |

## Properties

### AlternativeCertificate

Gets or sets the certificate the application uses instead of the [OriginalCertificate](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccertificaterequestedeventargs/members#originalcertificate).

<div class="api-signature" data-lang="csharp">

```csharp
public X509Certificate2 AlternativeCertificate { get; set; }
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Property AlternativeCertificate As X509Certificate2
```

</div>

**Property value**

[X509Certificate2](https://learn.microsoft.com/dotnet/api/system.security.cryptography.x509certificates.x509certificate2)

The certificate to use, or a null reference (Nothing in Visual Basic). The default value is the [OriginalCertificate](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccertificaterequestedeventargs/members#originalcertificate).

**Remarks**

A certificate other than the [OriginalCertificate](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccertificaterequestedeventargs/members#originalcertificate) is used by the application for this and for later starts or connects; the event does not occur again for it unless it is not valid. The certificate must contain its private key.

If the value is a null reference (Nothing in Visual Basic), a new certificate is created if [AutoCreateCertificate](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccertificaterequestedeventargs/members#autocreatecertificate) is true; otherwise the [OriginalCertificate](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccertificaterequestedeventargs/members#originalcertificate) remains in use, if there is one.

### AutoCreateCertificate

Gets value indicating whether the framework will automatically create a new [X509Certificate2](https://learn.microsoft.com/dotnet/api/system.security.cryptography.x509certificates.x509certificate2) instance by its own if [AlternativeCertificate](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccertificaterequestedeventargs/members#alternativecertificate) is a null reference (Nothing in Visual Basic).

<div class="api-signature" data-lang="csharp">

```csharp
public bool AutoCreateCertificate { get; }
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public ReadOnly Property AutoCreateCertificate As Boolean
```

</div>

**Property value**

[Boolean](https://learn.microsoft.com/dotnet/api/system.boolean)

The value true if the framework will automatically create a new [X509Certificate2](https://learn.microsoft.com/dotnet/api/system.security.cryptography.x509certificates.x509certificate2) by its own if [AlternativeCertificate](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccertificaterequestedeventargs/members#alternativecertificate) is a null reference (Nothing in Visual Basic); otherwise the value false.

**Remarks**

The value is always false for a [Reason](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccertificaterequestedeventargs/members#reason) which indicates that other applications refuse the certificate (e.g. [TimeInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccertificatevalidationresult/#timeinvalid)), because such a certificate is never replaced automatically (see [CertificateRequested](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcapplicationinstance/members#certificaterequested)).

### OriginalCertificate

Gets or sets the [X509Certificate2](https://learn.microsoft.com/dotnet/api/system.security.cryptography.x509certificates.x509certificate2) instance determined, evaluated and not used upon [Reason](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccertificaterequestedeventargs/members#reason).

<div class="api-signature" data-lang="csharp">

```csharp
public X509Certificate2 OriginalCertificate { get; }
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public ReadOnly Property OriginalCertificate As X509Certificate2
```

</div>

**Property value**

[X509Certificate2](https://learn.microsoft.com/dotnet/api/system.security.cryptography.x509certificates.x509certificate2)

The [X509Certificate2](https://learn.microsoft.com/dotnet/api/system.security.cryptography.x509certificates.x509certificate2) instance automatically determined or a null reference (Nothing in Visual Basic) in case there no certificate information could be found.

### Reason

Gets one of the members defined by the [OpcCertificateValidationResult](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccertificatevalidationresult/) enumeration which provides the outcome of the evaluation process of the [OriginalCertificate](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccertificaterequestedeventargs/members#originalcertificate) information.

<div class="api-signature" data-lang="csharp">

```csharp
public OpcCertificateValidationResult Reason { get; }
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public ReadOnly Property Reason As OpcCertificateValidationResult
```

</div>

**Property value**

[OpcCertificateValidationResult](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccertificatevalidationresult/)

One of the members defined by the [OpcCertificateValidationResult](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccertificatevalidationresult/) enumeration.

**Remarks**

The reasons which occur are listed at [CertificateRequested](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcapplicationinstance/members#certificaterequested).
