-2

How to Decode a CSR in .net,php,cgi,etc

wth a output like

CN OU O L S C

user1183408
  • 1
  • 1
  • 1
  • As you don't appear to have started coding yet, read-up on this first: http://en.wikipedia.org/wiki/Certificate_signing_request – rene Feb 01 '12 at 18:19
  • i have started coding but i do not know were to start – user1183408 Feb 02 '12 at 07:16
  • Welcome to Stack Overflow. I'm afraid we will not be able to help you since your question lacks detail. What did you try so far, what was the result? Please also read http://stackoverflow.com/questions/how-to-ask –  Feb 02 '12 at 13:04

2 Answers2

1

Easy in PHP:

$csr=$_POST['txtcsr'];  // Copy CSR to a variable
$data=openssl_csr_get_subject($csr);  // Get the subject of the CSR
print_r($data); // Print the output as an array:

Output: Array ( [C] => US [ST] => Minnesota [L] => Shakopee [O] => Test Organization [OU] => IT Arhitecture [CN] => your.domain [emailAddress] => your@email.com)

Tip: To get the function work, the server must have the OPENSSL_CNF environment variable correctly set.

Axell
  • 11
  • 1
  • Any suggestion for how to get following additional information ? - Signature algorithm - Key algorithm - Key size and SAN (Subject Alternative Names) if it exist Thanks – Vijay Lathiya Mar 25 '20 at 05:06
0

Look at OpenSSL modules for php and python for example. Php OpenSSL Python OpenSSL You can check php openssl_x509_parse() function or use something like proc_open, os.popen to call openssl tool to do all the job and get results.

insider
  • 1,818
  • 2
  • 17
  • 15