在php中生成证书请求

php*_*php -1 php ssl command-line system function

我有一张这样的桌子

<table  width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr> 
            <td class="TitleBar">Generate CSR</td>
            </tr>
        </table>
     <table  cellspacing="0" border="0" width="100%">

         <tr>               
            <td>Country Name(only two letters) :</td>
            <td >
            <input name="countryname" type="text"  id="countryname" MaxLength="2"/>
            </td>
        </tr>  
        <tr>                
            <td>State or Province Name :</td>
            <td> 
            <input name="province" type="text" id="province"/>
            </td>
         </tr>
         <tr>               
        <td>Locality Name :</td>
            <td >
            <input name="localityname" type="text"  id="localityname"/>
            </td>
        <tr>                
        <td>Organization Name :</td>
            <td> 
            <input name="organizationname" type="text" class="style16" id="organizationname"/>
            </td>
         </tr> 
         <tr>           
         <td>Organizational Unit Name :</td>
                <td > 
                <input name="organizationunit" type="text" id="organizationunit"/>
                </td>
         </tr>
         <tr>               
        <td>Common Name :</td>
            <td> 
            <input name="commonname" type="text"  id="commonname"/>
            </td>
         </tr>
            <tr>                
        <td>Email Address :</td>
            <td > 
            <input name="email" type="text"  id="email"/>
            </td>
         </tr>
            <tr>
            <td style="padding-top:15px padding-bottom:10px" align="right"> 
             <input name="gencsr" type="submit"  id="button" value="Generate CSR" class="FormButton" />
            </td>

            </tr></table>
Run Code Online (Sandbox Code Playgroud)

输入所有信息后,我想生成证书请求

在以下路径我能做什么?

#Generating a cert request
openssl req -new -nodes -out /portal/data/config/certificate/vendor/requests/couffin-req.pem -keyout /portal/data/config/certificate/vendor/requests/couffin-req.key -subj "/C=IN/ST=MAHARASHTRA/L=MUMBAI/O=Couffin Inc/OU=Sales/CN=www.couffin.itpl" -config /portal/data/config/certificate/vendor/openssl.cnf

#Signing a cert request
openssl ca -policy policy_anything -batch -out /portal/data/config/certificate/vendor/certs/couffin-cert.pem -config /portal/data/config/certificate/vendor/conf/openssl.cnf -infiles /portal/data/config/certificate/vendor/requests/couffin-req.pem
Run Code Online (Sandbox Code Playgroud)

注意: - 我想在系统命令行程序中执行

phi*_*hag 6

您应该使用php的ssl模块,而不是调用命令行程序.要使用它生成证书,请调用该openssl_csr_new函数.

  • @php对不起 虽然我们可以帮助您完成stackoverflow上的简短编程任务,但我们无法为您编写整个应用程序.用伪代码布局程序(如果必须,在纸上,没有语法).这应该是这样的:1.解析提交的输入(提示:使用`$ _POST`)2.生成私钥(提示:使用[`openssl_pkey_new`](http://php.net/manual/en/function.openssl- pkey-new.php))3.生成CSR(参见答案)4.将结果呈现给用户/存储它.如果您遇到***这些步骤的问题,请随时提出一个新的问题,但显示到目前为止您已经获得了什么PHP代码. (3认同)
  • @php好吧,如果你真的想要一个外部程序(你为什么要这样做呢?它更复杂),请使用php的[`exec`](http://php.net/manual/en/function.exec. php)函数来调用它. (3认同)
  • @php如果你的老板告诉你应该使用什么PHP功能,他会严重过度管理这个问题.问他命令行功能相对于内置功能的优势是什么(可能只有一个).如果他没有意义,就要开始寻找更好的工作.正如我所说,首先布置伪代码,然后逐步完善它.即使我想要,我也不可能编写你需要的整个PHP代码.如果您对*特定*步骤有疑问,请随时在新问题中提问. (2认同)
  • @php我担心你将不得不学习如何编写php来编程php.我建议你联系你的老板,并要求进行php培训,因为你似乎已经超越了你的头脑.正如我所说,即使我想为你编码一切(我为什么要为你付钱,而不是我),我不能,因为我不知道你的确切设置,条件和要求. (2认同)