Guest User

Untitled

a guest
Feb 7th, 2018
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. <?php
  2.  
  3. function write_cert($cert) {
  4. echo "$cert";
  5.  
  6. $myFile = "/tmp/tmp1234.spkac";
  7. $fh = fopen($myFile, 'w') or die("can't open file");
  8. fwrite($fh, $cert);
  9. fclose($fh);
  10.  
  11.  
  12. $opensslconf = "/etc/ssl/openssl.cnf";
  13. $days = 36500;
  14. $certfolder = "/tmp";
  15. $uniq = "1234";
  16. $capw = "";
  17.  
  18.  
  19. $command = "/usr/bin/openssl ca -config ".$opensslconf." -days ".$days." -notext \
  20. -batch -spkac ".$certfolder.$uniq.".spkac -out ".$certfolder.$uniq." -passin pass:'".$capw."' 2>&1";
  21. $output = shell_exec($command);
  22.  
  23.  
  24.  
  25. echo $command;
  26. echo "\n" ;
  27.  
  28.  
  29. }
  30.  
  31. echo "<pre>";
  32.  
  33. $key = $_REQUEST['pubkey'];
  34.  
  35.  
  36. $username = "Joe";
  37. $CAmail = "joe@example.org";
  38. $CAorg = "AA Ltd";
  39. $CAcity = "AA";
  40. $CAcountry = "AA";
  41. $localityName = "Prage";
  42.  
  43. $keyreq = "SPKAC=".str_replace(str_split(" \t\n\r\0\x0B"), '', $key);
  44. $keyreq .= "\nCN=".$username;
  45. $keyreq .= "\nemailAddress=".$CAmail;
  46. $keyreq .= "\n0.OU=".$CAorg." client certificate";
  47. $keyreq .= "\norganizationName=".$CAorg;
  48. $keyreq .= "\ncountryName=".$CAcountry;
  49. $keyreq .= "\nstateOrProvinceName=".$CAcity;
  50. $keyreq .= "\nlocalityName=".$CAcity;
  51.  
  52.  
  53.  
  54.  
  55. write_cert($keyreq);
  56. echo "</pre>";
  57.  
  58. ?>
  59.  
  60. <form>
  61. <keygen name="pubkey" challenge="randomchars">
  62. <input type="submit" name="createcert" value="Generate">
  63. </form>
Add Comment
Please, Sign In to add comment