secCertificateInformation (Functionblock)

Top  Previous  Next

Architecture:

NX32L

Firmware version:

1.08.00


The secCertificateInformation function retrieves information about a certificate installed on the device.

 

 

Input:

name : STRING

The name of the certificate.

 

 

Output:

status : BOOL

True if the certificate is found.

 

type : SINT

The type of certificate.

1

- A root CA certificate.

2

- A certificate chain.

 

subject : STRING

The subject string.

 

issuer : STRING

The issuer string.

 

serial : STRING

The serial number of the certificate.

 

valid_from : DINT

The time (linsec) from when the certificate is valid.

 

valid_to : DINT

After this time (linsec), the certificate is not valid.

 

key : BOOL

True if the certificate includes an encryption key.

 

 

Declaration:

FUNCTION_BLOCK secCertificateInformation;
VAR_INPUT
   name       : STRING;
END_VAR;
VAR_OUTPUT
   status     : BOOL;
   type       : SINT;
   subject    : STRING;
   issuer     : STRING;
   serial     : STRING;
   valid_from : DINT;
   valid_to   : DINT;
   key        : BOOL;
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
VAR
   sec : secCertificateInformation;
END_VAR;
 
FUNCTION show_certificate
VAR_INPUT
   name : STRING;
END_VAR;
VAR
   str  : STRING;
END_VAR;
 
   // Get information
   sec(name := name);
 
   // Output
   DebugMsg(message := "------------------------------");
   DebugMsg(message := " Certificate [" + name + "]");
   IF sec.status THEN
      DebugFmt(message := "   type     = \1", v1 := sec.type);
      DebugMsg(message := "   subject  = [" + sec.subject + "]");
      DebugMsg(message := "   issuer   = [" + sec.issuer + "]");
      DebugMsg(message := "   serial   = [" + sec.serial + "]");
      DebugMsg(message := "   valid");
      DebugFmt(message := "     from   = \4", v4 := sec.valid_from);
      DebugFmt(message := "     to     = \4", v4 := sec.valid_to);
      DebugFmt(message := "   key      = \1", v1 := INT(sec.key));
   ELSE
      DebugMsg(message := "   Not found!");
   END_IF;
 
END_FUNCTION;