You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.4 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <?php
  2. $Data = array();
  3. $Data[] = "oid_section = OIDs";
  4. $Data[] = "[ req ]";
  5. $Data[] = "default_bits = 2048";
  6. $Data[] = "encrypt_key = no";
  7. $Data[] = "default_md = sha256";
  8. $Data[] = "distinguished_name = dn";
  9. $Data[] = "prompt = no";
  10. $Data[] = "[ OIDs ]";
  11. $Data[] = "MySensationalOID=1.2.3.4";
  12. $Data[] = "MyOutstandingOID=2.3.4.56";
  13. $Data[] = "[ dn ]";
  14. $Data[] = "CN = Evgeny Gagua";
  15. $Data[] = "emailAddress = poocka@gmail.com";
  16. $Data[] = "O = Dr. Frucht Systems Ltd.";
  17. $Data[] = "C = IL";
  18. $Data[] = "MySensationalOID={$argv[1]}";
  19. $Data[] = "[ req_ext ]";
  20. $Data[] = "subjectAltName = email:gagua@gmail.com";
  21. $Data[] = "MyOutstandingOID=Evgeny Gagua";
  22. if( count( $argv ) > 1 ){
  23. $TMP = md5(time());
  24. $FD = fopen( $TMP.".conf", "w+" );
  25. if( $FD ){
  26. $JJ = implode( "\n", $Data ) . "\n";
  27. fprintf( $FD, $JJ );
  28. fclose( $FD );
  29. if( 0 ){
  30. $L = `openssl genrsa -out {$TMP}.key 2048`;
  31. $L = `openssl req -sha256 -verbose -config {$TMP}.conf -extensions req_ext -new -nodes -key {$TMP}.key -out {$TMP}.csr`;
  32. } else {
  33. $L = `openssl req -new -config {$TMP}.conf -key host.key -out {$TMP}.csr`;
  34. };
  35. $L = `openssl x509 -req -CA rootCA.crt -CAkey rootCA.key -in {$TMP}.csr -out {$TMP}.crt -days 365 -CAcreateserial`;
  36. unlink( $TMP . '.conf' );
  37. unlink( $TMP . '.csr' );
  38. echo "{$TMP}.crt";
  39. };
  40. };
  41. ?>