Search code examples
asp.netvalidationcsr

Validate CSR text in a web application


There is a web user interface through which user is posting csr text in the website. there is a textbox in which user paste the csr text that is generated by a tool.

Previously i was validating the text , by checking if there is ---Begin Request --- and ---End Request---- present in the text.

But

---Begin Request ---
blah blah 
---End Request----

is not a valid CSr text, But it is validated by my site since it contains the begin and end tag. How can i validate the CSR text, IS there any web api present to which i can send the request and it can validate the request and send the response back.


Solution

  • request = new CX509CertificateRequestPkcs10();
    request.InitializeDecode("Actual csr", EncodingType.XCN_CRYPT_STRING_BASE64REQUESTHEADER);
    

    replace "Actual CSR" with the csr provided by the user.

    you can use the above method which will validate if it is a valid BASE64 Request or not.(i.e. a valid CSR)