全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 3191|回复: 1

php怎么写个csr在线生成

[复制链接]
发表于 2013-6-5 20:46:58 | 显示全部楼层 |阅读模式
本帖最后由 holinhot 于 2013-6-5 20:49 编辑
  1. <?php
  2. // Fill in data for the distinguished name to be used in the cert
  3. // You must change the values of these keys to match your name and
  4. // company, or more precisely, the name and company of the person/site
  5. // that you are generating the certificate for.
  6. // For SSL certificates, the commonName is usually the domain name of
  7. // that will be using the certificate, but for S/MIME certificates,
  8. // the commonName will be the name of the individual who will use the
  9. // certificate.
  10. $dn = array(
  11.     "countryName" => "CN",
  12.     "stateOrProvinceName" => "Somerset",
  13.     "localityName" => "Glastonbury",
  14.     "organizationName" => "The Brain Room Limited",
  15.     "organizationalUnitName" => "PHP Documentation Team",
  16.     "commonName" => "qq.com",
  17.     "emailAddress" => "wez@example.com"
  18. );

  19. $config = array(
  20.    "digest_alg" => "sha1",
  21.    "private_key_bits" => 2048,
  22.    "private_key_type" => OPENSSL_KEYTYPE_DSA,
  23.    "encrypt_key" => false,
  24. );
  25. // Generate a new private (and public) key pair
  26. $privkey = openssl_pkey_new();

  27. // Generate a certificate signing request
  28. $csr = openssl_csr_new($dn, $privkey);

  29. // You will usually want to create a self-signed certificate at this
  30. // point until your CA fulfills your request.
  31. // This creates a self-signed cert that is valid for 365 days
  32. $sscert = openssl_csr_sign($csr, null, $privkey, 365);

  33. // Now you will want to preserve your private key, CSR and self-signed
  34. // cert so that they can be installed into your web server, mail server
  35. // or mail client (depending on the intended use of the certificate).
  36. // This example shows how to get those things into variables, but you
  37. // can also store them directly into files.
  38. // Typically, you will send the CSR on to your CA who will then issue
  39. // you with the "real" certificate.
  40. openssl_csr_export($csr, $csrout) and var_dump($csrout);
  41. openssl_x509_export($sscert, $certout) and var_dump($certout);
  42. openssl_pkey_export($privkey, $pkeyout, "mypassword") and var_dump($pkeyout);

  43. // Show any errors that occurred here
  44. while (($e = openssl_error_string()) !== false) {
  45.     echo $e . "\n";
  46. }
  47. ?>




复制代码
怎么不行啊。说我的key加密不是2048bit
我不是指定了2048吗


还有神马方式
QQ图片20130605205726.jpg (49.66 KB, 下载次数: 15)
 楼主| 发表于 2013-6-5 20:51:33 | 显示全部楼层
27.$privkey = openssl_pkey_new();
27.$privkey = openssl_pkey_new($config);
没作用
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2024-4-24 11:13 , Processed in 0.067859 second(s), 13 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表