2
Answers

Urgent Help !! In certifcate enrollment in Windows CA using C# ( XENROLL.dll)

Ask a question

Hi every body

I am doing a project in which I have a Windows Certificate Authority server and RADIUS server (IAS RADIUS server under windows ) . In this project the clients will login to the domain and get certificates from CA. I know this can be done through Windows configuration, but it's not good. I want to understand what is going behind, so I want to develop my own code. In brief, My question is :

I want to do certificate enrollment and request through C# program. I saw many codes in websites. They are using XENROLL.dll library to do enrollment, but  I couldn't understand. Sorry I am still new in C#, so I need any tutorial or guide about this to guide me how can I do it.

I don't know from where these guys got tutorials about Certifcate enrollment, request ...... etc

It's hard to start a project on this without deep understanding of the methods used and classes.

 

Here is an example of the codes I found. This to give you a total figure of what I mean

*****************************

int creationState;
string CertificateTemplate = "My Certificate Template";
string ProviderName ="Microsoft Enhanced Cryptographic Provider v1.0";
string EmailCertOID = "1.3.6.1.5.5.7.3.4" ; //Email certificate
// creating cert request:

XENROLLLib.CEnroll certEnroll = new XENROLLLib.CEnroll();
certEnroll.GenKeyFlags = 1024 * (256*256);
certEnroll.GenKeyFlags = CRYPT_EXPORTABLE;
certEnroll.UseExistingKeySet = 0;
certEnroll.ContainerName() = cert;
certEnroll.addCertTypeToRequest (CertificateTemplate);
certEnroll.ProviderName =ProviderName;
string dn = "CN="+ CommonName.Text +",E="+ Email.Text +",O="+
Organisation.Text +",L="+ Stadt.Text +",S="+ State.Text
+",C="+Countrycode.Text+"";
string req = certEnroll.createPKCS10(dn, EmailCertOID);
int CR_IN_BASE64 = 0x1;
int CR_IN_PKCS10 = 0x100;

CERTCLIENTLib.CCertRequest certRequest = new CERTCLIENTLib.CCertRequest();
creationState = certRequest.Submit(CR_IN_BASE64 | CR_IN_PKCS10, req,
"", @"Certserver\MyCertCA");

***************************************

 

Please Please Please if any one know something about this PLEASE AGAIN guide me. It is toooo urgent. I have just two months to submit the project


Answers (2)