Set certificate's duration when automatically created

Questions regarding the use of the .NET SDK 2.0 for Server or Client development or integration into customer products ...

Moderator: uasdknet

Post Reply
User avatar
baldo
Hero Member
Hero Member
Posts: 25
Joined: 19 Nov 2019, 12:15

Set certificate's duration when automatically created

Post by baldo »

Code: Select all

ApplicationInstance.Default.ApplicationCertificate.ValidTo = DateTime.Now.AddYears(10);

// setting this flag will create the certificate automatically if it does not already exist,
// however, the process must be running with administrative priviledges. If this flag is false
// the certificate has to be created manually by another tool or by running this process once
// with administrative priviledges and the /install argument.
ApplicationInstance.Default.AutoCreateCertificate = true;
Looking at the demos, I let this option (last line of code) set to true, and I like it because it creates a certificate automatically.

I was wondering how I could have customized the certificate's duration. UaSchema has a "ValidTo" property (first line) but I cannot set it like that from code.
Any advice about how to do it in this scenario?

User avatar
Support Team
Hero Member
Hero Member
Posts: 3064
Joined: 18 Mar 2011, 15:09

Re: Set certificate's duration when automatically created

Post by Support Team »

Hi,

in UnifiedAutomation.UaBase.CreateCertificateSettings you can find the "LifetimeInMonths",
which is added to "now" when creating the certificate (validFrom + LifeTimeInMonth = validTo)
Best regards
Unified Automation Support Team

Post Reply