返回首页

嘿所有,

我有一个证书请求/入学问题。我得到这个错误:

CertEnroll::CX509Enrollment::_EnrollWizard: The system cannot find the file specified. 0x80070002 (WIN32: 2)

我要为另一个用户创建一个证书,所以我使用基本身份验证,因为代表团和模拟用户要求的证书,记录。

如果我要求域用户的证书,我编写和出版,我得到的权证书。当我与其他用户发布的解决方案,我可以要求的证书,也为这个用户。如果它是一个其他的用户,我得到的错误。

第一类:
{C} 证书请求:

class EnrollCertificate

    {

        public static void EnrollCert(

            string templateName,

            string subjectName,

            string friendlyName,

            WindowsIdentity wi)

        {

            // create a CX509Enrollment object

            CX509Enrollment objEnroll = new CX509Enrollment();

           

            // initialize the CX509Enrollment object from template

            objEnroll.InitializeFromTemplateName(

                X509CertificateEnrollmentContext.ContextUser,

                templateName);

            

            // first get the request

            IX509CertificateRequest iRequest = objEnroll.Request;

 

            // then get the inner PKCS10 request

            IX509CertificateRequest iInnerRequest =

                iRequest.GetInnerRequest(InnerRequestLevel.LevelInnermost);

            IX509CertificateRequestPkcs10 iRequestPkcs10 =

                iInnerRequest as IX509CertificateRequestPkcs10;

 

            // create CX500DistinguishedName

            CX500DistinguishedName objName = new CX500DistinguishedName();

            objName.Encode(subjectName, X500NameFlags.XCN_CERT_NAME_STR_NONE);

 

            // set up the subject name

            iRequestPkcs10.Subject = objName;

 

            // set up friendly name

            objEnroll.CertificateFriendlyName = friendlyName;

 

            // enroll for the certificate, which should install the certficate

            // in store if the certificate is successfully issued by CA

            objEnroll.Enroll();

            

        }

    }


我不知道什么是错的。
你有什么想法?

回答

评论会员: 时间:2