NET API
HSM Dinamo
Loading...
Looking for...
No entries found
spb_import_activate.cs

Example of importing, activating and retrieving a certificate and its information using the SPB (Brazilian Payment System) APIs.

See Note on examples.
using Dinamo.Hsm;
using System;
using System.Text;
namespace SPBImportActivate
{
class Program
{
private static String strAddr = "127.0.0.1";
private static String strUsrId = "spb";
private static String strPwd = "12345678";
static void Main(string[] args)
{
string domain = "SPB";
string certId = "11111111@SPB"; // ISPB@DOMAIN
try {
/* Connect */
api.Connect(strAddr, strUsrId, strPwd);
/* SPB certificate */
byte[] certData = Convert.FromBase64String("MIIDbDCCAlQCCQDF0Z57hjZCOzANBgkqhkiG9w0BAQUFADBYMRgwFgYDVQQDDA9EaW5hbW8gTmV0d29ya3MxETAPBgNVBAcMCEJyYXNpbGlhMQswCQYDVQQIDAJERjELMAkGA1UEBhMCQlIxDzANBgNVBAsMBkNTUEItNjAeFw0xMzExMTMwMDA0MDhaFw0zMzA3MzEwMDA0MDhaMIGXMQswCQYDVQQGEwJCUjETMBEGA1UECgwKSUNQLUJyYXNpbDEWMBQGA1UECwwNSVNQQi0xMTExMTExMTEXMBUGA1UECwwOU0lTQkFDRU4tMTExMTExIjAgBgNVBAMMGUJhbmNvIGRlIHRlc3RlIDExMTExIFQwMDExETAPBgNVBAcMCEJyYXNpbGlhMQswCQYDVQQIDAJERjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKICeu4eCP9R8qiiNoYOKOBAsRjam1LGsXhIijqkUnac8RIQhmhgtgZ3KZSTshFBBNdd60PDhVZAZqnfT4PIejQdwmiOYAKLcXKgWkyrj+rvKTFvzkNArzZbDUx932VAWauvQz/VBfOEZy9UzpR2IE053hkwRffEdhqYsfxzEhXmSiBah8otjN6Arm+aPrNzLuRlSunXgKRieoCF74iUB4CxZ4RzkSi5sZHbhHxTGnjP0GkNvQNOzAsoAFS8MtMlAAUbD/3LgHFXREhtYoKPgIacTvWJK5xHOGrhg+MKGx/vTjtymrcbmEBJ1Yl/TwMOldS+DC+AWMxDdL10einiPqcCAwEAATANBgkqhkiG9w0BAQUFAAOCAQEATSfWli73+6/UclVloYra5SsdRNs++XEGZwB3vk3DOrdNMRznrG5XCkvlAyVcRbjUfDq5zeYMjAeHVTCXx595VxHAfW+PP0MsEOHncpOjyjwXCIyhkoeOsIjlHuBRj9jgvisurx6+Hc8N/yC8mjxcnOIp88m1u2tIB13i55T/U9iaSX
/* Import certificate */
api.SPBImportCertificate(domain, certData);
/* Retrieve certificate information */
var certInfo = api.SPBGetCertificateInfo(certData);
/* Activates certificate */
api.SPBActivateCertificate(domain, certInfo.szCA, certInfo.szSN);
/* Retrieves certificate */
var exportedCertData = api.SPBGetCertificate(certId);
} catch (DinamoException e) {
Console.Out.WriteLine(e.Message);
Console.Out.WriteLine(e.ErrorCode);
} finally{
api.Disconnect(); // disconnects
}
}
}
}
API class for accessing HSM functionalities Dinamo. In this class you can program using...
Definition DinamoClient.cs:93
Exception class for errors from Dinamo.
Definition DinamoException.cs:10
override string Message
Definition DinamoException.cs:42
int ErrorCode
Definition DinamoException.cs:26
void Connect(string User, string Password)
Establishes an encrypted connection to the HSM using the load balance settings.
Definition DinamoClient.cs:562
void Disconnect(bool flagClose)
Terminates the connection to the HSM.
Definition DinamoClient.cs:814
DinamoApi.SPB_CERT_X509_INFO SPBGetCertificateInfo(byte[] certificate)
Retrieves information from the certificate.
Definition DinamoClient.cs:6899
byte[] SPBGetCertificate(string strIdCertificate)
Retrieves a certificate stored in a namespace in the HSM.
Definition DinamoClient.cs:6278
void SPBImportCertificate(string szDomain, byte[] bCertificate)
Import a certificate into an HSM namespace.
Definition DinamoClient.cs:6797
void SPBActivateCertificate(string szDomain, string szCA, string szSN, bool isCIPCertificate=false)
Activates a certificate that has already been imported into the HSM. If another certificate is active,...
Definition DinamoClient.cs:6822
Namespace denoting a set of functions for accessing the HSM Dinamo and their respective exceptions.
Definition DinamoClient.cs:12