Ejemplo n.º 1
0
        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)));
        }
Ejemplo n.º 2
0
        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)));
        }
Ejemplo n.º 3
0
        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));
        }