Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.22 KB | None | 0 0
  1. <?php
  2. $cwd=getcwd();
  3. $distname= array(
  4. "countryName" => "CA",
  5. "stateOrProvinceName" => "Ontario",
  6. "localityName" => "Toronto",
  7. "organizationName" => "G4 Apps",
  8. "organizationalUnitName" => "Development",
  9. "commonName" => "Mark Lane",
  10. "emailAddress" => "nobody at gmail.com"
  11. );
  12. $password = 'seanix';
  13.  
  14. $cacert_location=$cwd."/certs/CA/g4CA.crt";
  15. $cakey_location=$cwd."/certs/CA/g4CA.key";
  16. $cnf=$cwd.'/certs/myopenssl.cnf';
  17. $configArgs = array(
  18. 'config' =>$cnf
  19. );
  20. ?>
  21.  
  22. <?php
  23. function makekey($password,$configArgs) {
  24. $key= openssl_pkey_new($configArgs);
  25. //print_r($configArgs);
  26. openssl_pkey_export($key, $pkeyout,$password);
  27. if (($e=openssl_error_string()) ==false) return $pkeyout;
  28. else {
  29. do {
  30.  
  31. echo $e . "<BR>";
  32. } while($e=openssl_error_string());
  33. return -1;
  34. }
  35. }
  36. ?>
  37.  
  38. <?php
  39. function newcsr($distname,$key,$configArgs) {
  40. $csr=openssl_csr_new($distname,$key,$configArgs);
  41. openssl_csr_export($csr, $csrout);
  42. if (($e=openssl_error_string()) ==false) return $csrout;
  43. else {
  44. do {
  45.  
  46. echo $e . "<BR>";
  47. } while($e=openssl_error_string());
  48. return -1;
  49. }
  50. }
  51. ?>
  52.  
  53. HOME = .
  54. RANDFILE = $ENV::HOME/.rnd
  55.  
  56. oid_section = new_oids
  57.  
  58.  
  59. [ new_oids ]
  60.  
  61.  
  62. tsa_policy1 = 1.2.3.4.1
  63. tsa_policy2 = 1.2.3.4.5.6
  64. tsa_policy3 = 1.2.3.4.5.7
  65.  
  66. ####################################################################
  67. [ ca ]
  68. default_ca = g4CA
  69.  
  70. ####################################################################
  71. [ g4CA ]
  72.  
  73. dir = /home/g4apps/secure.g4apps.com/generator/certs
  74. certs = $dir/
  75. crl_dir = $dir/crl
  76. database = $dir/index.txt
  77.  
  78.  
  79. new_certs_dir = $dir/newcerts
  80.  
  81. certificate = $dir/CA/g4CA.crt
  82. serial = $dir/serial
  83. crlnumber = $dir/crlnumber
  84.  
  85. crl = $dir/CA/g4CA.crl
  86. private_key = $dir/CA/g4CA.key
  87. RANDFILE = $dir/private/.rand
  88.  
  89. x509_extensions = usr_cert
  90.  
  91. name_opt = ca_default
  92. cert_opt = ca_default
  93.  
  94.  
  95. default_days = 365 # how long to certify for
  96. default_crl_days= 30 # how long before next CRL
  97. default_md = default # use public key default MD
  98. preserve = no # keep passed DN ordering
  99.  
  100. policy = policy_match
  101.  
  102.  
  103. [ policy_match ]
  104. countryName = match
  105. stateOrProvinceName = match
  106. organizationName = match
  107. organizationalUnitName = optional
  108. commonName = supplied
  109. emailAddress = optional
  110.  
  111. [ policy_anything ]
  112. countryName = optional
  113. stateOrProvinceName = optional
  114. localityName = optional
  115. organizationName = optional
  116. organizationalUnitName = optional
  117. commonName = supplied
  118. emailAddress = optional
  119.  
  120. ####################################################################
  121. [ req ]
  122. default_bits = 2048
  123. default_md = md5
  124. default_keyfile = privkey.pem
  125. distinguished_name = req_distinguished_name
  126. attributes = req_attributes
  127. x509_extensions = v3_ca # The extentions to add to the self signed cert
  128.  
  129. string_mask = utf8only
  130.  
  131. [ req_distinguished_name ]
  132. countryName = Country Name (2 letter code)
  133. countryName_default = CA
  134. countryName_min = 2
  135. countryName_max = 2
  136.  
  137. stateOrProvinceName = State or Province Name (full name)
  138. stateOrProvinceName_default = ON
  139.  
  140. localityName = Locality Name (eg, city)
  141. localityName_default = Toronto
  142.  
  143. 0.organizationName = Organization Name (eg, company)
  144. 0.organizationName_default = G4 Apps
  145.  
  146.  
  147.  
  148. organizationalUnitName = Organizational Unit Name (eg, section)
  149.  
  150. commonName = Common Name (eg, your name or your server's hostname)
  151. commonName_max = 64
  152.  
  153. emailAddress = Email Address
  154. emailAddress_default = lmlane@gmail.com
  155. emailAddress_max = 64
  156.  
  157.  
  158. [ req_attributes ]
  159. challengePassword = A challenge password
  160. challengePassword_min = 4
  161. challengePassword_max = 20
  162.  
  163. unstructuredName = An optional company name
  164.  
  165. [ usr_cert ]
  166.  
  167. nsComment = "OpenSSL Generated Certificate"
  168.  
  169. subjectKeyIdentifier=hash
  170. authorityKeyIdentifier=keyid,issuer
  171.  
  172.  
  173.  
  174. [ v3_req ]
  175.  
  176.  
  177. basicConstraints = CA:FALSE
  178. keyUsage = nonRepudiation, digitalSignature, keyEncipherment
  179.  
  180. [ v3_ca ]
  181.  
  182.  
  183. subjectKeyIdentifier=hash
  184.  
  185. authorityKeyIdentifier=keyid:always,issuer
  186. basicConstraints = CA:true
  187.  
  188.  
  189. [ crl_ext ]
  190.  
  191. authorityKeyIdentifier=keyid:always
  192.  
  193. [ proxy_cert_ext ]
  194. basicConstraints=CA:FALSE
  195.  
  196. nsComment = "OpenSSL Generated Certificate"
  197.  
  198. subjectKeyIdentifier=hash
  199. authorityKeyIdentifier=keyid,issuer
  200.  
  201. proxyCertInfo=critical,language:id-ppl-anyLanguage,pathlen:3,policy:foo
  202.  
  203. ####################################################################
  204. [ tsa ]
  205.  
  206. default_tsa = tsa_config1
  207.  
  208. [ tsa_config1 ]
  209.  
  210. dir = ./demoCA
  211. serial = $dir/tsaserial
  212. crypto_device = builtin
  213. signer_cert = $dir/tsacert.pem
  214.  
  215. certs = $dir/cacert.pem
  216. signer_key = $dir/private/tsakey.pem
  217. default_policy = tsa_policy1
  218. other_policies = tsa_policy2, tsa_policy3
  219. digests = md5, sha1
  220. accuracy = secs:1, millisecs:500, microsecs:100
  221. clock_precision_digits = 0
  222. ordering = yes
  223.  
  224. tsa_name = yes
  225. ess_cert_id_chain = no
  226.  
  227. $res = openssl_pkey_new();
  228. openssl_pkey_export($res, $privkey);
  229. var_dump(openssl_error_string());
  230. var_dump($privkey);
  231.  
  232. string(68) "error:0E06D06C:configuration file routines:NCONF_get_string:no value"
  233. string(887) "-----BEGIN RSA PRIVATE KEY-----
  234. MIICXQIBAAKBgQDdh4FiOEtUZzvTSnlb/pJHjmsS9rOHQ7PU2WOO6ZHxYRIgK1NR
  235. ReY7bBwEsT2ziUpx0b8K2Fx4m+XovzysB/lVrKbrdbHoVtGuJGZjYSXgFlCRTBu+
  236. +TnAPUBF0LGJfxfVzjOkHzsh02lH3fvzFpFgRZRWs4za+vVzIweeOweYTwIDAQAB
  237. AoGANZD5iS2BkZQw1COS+tqwtlrKq1g6CwAk8NfsCfeSkaJeRqcTS3iydjXrBHtz
  238. JwGQnbsRDedJXOSdkE0Ft7dp44lijOAp1ngMDCKbabxVN2Go6b1d743HE0oIhFCC
  239. Dv2B9kf9vzeYy+0/BVCs5i4iPoKXJJTSJrWoDxrFEJWSJIkCQQDwe39bOFHmQlxz
  240. pbfT3DZ8Q311xFo6PewcAf7DTsikoPZANx0GQ41WdZj6/n4QVP4k+TnhZLiJzsH+
  241. p3RUrx8tAkEA69LsgPrQMZ0YjsE2vjRLdJmp1916G1xqSLIVWDUPd9Ns+MA8YKTx
  242. AQxC3dl3n+w24m7UlCThANlU/+2r0eoi6wJBAKIxGOdEJ/Cdp08UYNRR/Kl4t2A7
  243. SwNnChylt9awByEJsqwCv9+epe+/Jqt6AzouqK31LXV4AgJn4W1IMWyAJA0CQCp0
  244. 6/2AqnD0PpKc+JUf5yHT9H8Xsb8xUTVLUopx6xoAp5LVUUl5CKbOpU85ss7JAUyc
  245. 9YrCZPv5JNN6379ILwcCQQDDcjtNnhQHukQQQ8iVL9YCrWzyCgplTz3uktueT+Dd
  246. SDK1bCM4xDehfG3RKu1ZNx80Q0nzmi7FSPJ2md7qSIHc
  247. -----END RSA PRIVATE KEY-----
  248. "
  249.  
  250. default_md = md5
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement