public string GetServerVersion() { var serverVersionPtr = new IntPtr(); UInt32 dwError = VMCAAdaptor.VMCAGetServerVersionHA( _serverContext, ServerName, out serverVersionPtr); VMCAError.Check(dwError); string version = Marshal.PtrToStringAnsi(serverVersionPtr); VMCAAdaptor.VMCAFreeVersion(serverVersionPtr); return(version); }
public void CloseServer() { try { if (_serverContext != IntPtr.Zero) { VMCAAdaptor.VMCACloseServer(_serverContext); } } catch (Exception e) { throw e; } }
public X509Certificate2 GetVMCASignedCertificate(VMCAAdaptor.VMCA_PKCS_10_REQ_DATA certRequest, string privateKey, DateTime notBefore, DateTime notAfter) { IntPtr pCert = new IntPtr(); long nBefore = notBefore.ToTime_t(); long nAfter = notAfter.ToTime_t(); UInt32 dwError = VMCAAdaptor.VMCAGetSignedCertificateHA(_serverContext, ServerName, certRequest, privateKey, "", nBefore, nAfter, out pCert); VMCAError.Check(dwError); string certString = Marshal.PtrToStringAnsi(pCert); VMCAAdaptor.VMCAFreeCertificate(pCert); return(new X509Certificate2(ASCIIEncoding.ASCII.GetBytes(certString))); }
public string GetCSR(string privateKey) { IntPtr pCSR = new IntPtr(); var requestData = GetRequestData(); UInt32 result = VMCAAdaptor.VMCACreateSigningRequest(requestData, privateKey, "", out pCSR); VMCAError.Check(result); string csr = Marshal.PtrToStringAnsi(pCSR); VMCAAdaptor.VMCAFreeCSR(pCSR); return(csr); }
public X509Certificate2 GetRootCertificate() { IntPtr pCert = new IntPtr(); UInt32 dwError = VMCAAdaptor.VMCAGetRootCACertificateHA( _serverContext, ServerName, out pCert); VMCAError.Check(dwError); string certString = Marshal.PtrToStringAnsi(pCert); VMCAAdaptor.VMCAFreeCertificate(pCert); return(new X509Certificate2(ASCIIEncoding.ASCII.GetBytes(certString))); }
public VMCACertificate GetSelfSignedCertificate(string privateKey, DateTime notBefore, DateTime notAfter) { IntPtr pCert = new IntPtr(); var requestData = GetRequestData(); long nBefore = notBefore.ToTime_t(); long nAfter = notAfter.ToTime_t(); UInt32 result = VMCAAdaptor.VMCACreateSelfSignedCertificate(requestData, privateKey, "", nBefore, nAfter, out pCert); VMCAError.Check(result); string cert = Marshal.PtrToStringAnsi(pCert); VMCAAdaptor.VMCAFreeCertificate(pCert); return(new VMCACertificate(Client, cert)); }
void EnsureServerContext() { try { if (_serverContext != IntPtr.Zero) { return; } UInt32 result = VMCAAdaptor.VMCAOpenServerA( ServerName, UserName, DomainName, Password, 0, IntPtr.Zero, out _serverContext); VMCAError.Check(result); } catch (Exception) { UserName = ""; Password = ""; throw; } }
public void AddRootCertificate(string rootCert, string passPhrase, string privateKey) { UInt32 dwError = VMCAAdaptor.VMCAAddRootCertificate(ServerName, rootCert, passPhrase, privateKey); VMCAError.Check(dwError); }