Click or drag to resize

SatCheckKeyAndCert Method

Verify that the public key in an X.509 certificate matches the private key.

Namespace: FirmaSAT
Assembly: diFirmaSatNet (in diFirmaSatNet.dll) Version: 10.70.0.38178 (10.70.0.0)
Syntax
public static int CheckKeyAndCert(
	string keyFile,
	string password,
	string certFile
)

Parameters

keyFile  String
Name of private key file
password  String
Password for encrypted private key
certFile  String
X.509 certificate file or XML document with embedded certificado node

Return Value

Int32
Zero (0) if keys match or a negative error code.
Example
C#
int n = Sat.CheckKeyAndCert("emisor.key", "12345678a", "emisor.cer");
Console.WriteLine("Sat.CheckKeyAndCert returns {0}", n);
// Sat.CheckKeyAndCert returns 0

// Cert and key do not match ...
n = Sat.CheckKeyAndCert("emisor.key", "12345678a", "pac.cer");
Console.WriteLine("Sat.CheckKeyAndCert returns {0}", n);
// Sat.CheckKeyAndCert returns -21
Console.WriteLine(General.ErrorLookup(n));
// Match not found/No se pudo encontrar datos coincidente (NO_MATCH_ERROR)
Console.WriteLine(General.LastError());
// Private key does not match key in certificate/La clave privada no coincide con la clave del certificado
See Also