コード例 #1
0
        //get the issue Certificate from the ca
        public string getCertificate(int requestID)
        {
            int     iDisposition;
            int     status;
            string  strCAConfig;
            string  pstrCertificate;
            SqlLite sql = new SqlLite();

            pstrCertificate = null;
            CCertConfig  objCertConfig  = new CCertConfig();
            CCertRequest objCertRequest = new CCertRequest();

            try
            {
                strCAConfig     = objCertConfig.GetConfig(CC_DEFAULTCONFIG);              //connect to the ca
                iDisposition    = objCertRequest.RetrievePending(requestID, strCAConfig); //getting certificate stauts must before getting the cert
                pstrCertificate = objCertRequest.GetCertificate(CR_OUT_BASE64);           //retrive the Certificate
                status          = sql.updateCertInfo(pstrCertificate, requestID);         //update cert with more information
                if (status == 0)
                {
                    Certificate cert = new Certificate {
                        CertValue = pstrCertificate
                    };                                                                   //creatre cert with JSON type
                    string certJson = Newtonsoft.Json.JsonConvert.SerializeObject(cert); //creatre cert with JSON type
                    return(certJson);                                                    //return certificate
                }

                else
                {
                    return("error Update Certificate Table");
                }
            }

            catch (Exception ex)
            {
                return("error" + ex.Message);
            }
        }