Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Perl的PHP openssl等价物?_Php_Perl_Certificate_Openssl_Self Signed - Fatal编程技术网

Perl的PHP openssl等价物?

Perl的PHP openssl等价物?,php,perl,certificate,openssl,self-signed,Php,Perl,Certificate,Openssl,Self Signed,以下代码在perl中创建自签名证书的等效示例是什么 我所有可用的是Crypt::OpenSSL::RSA(如果有其他模块,请告诉我,以便我可以验证它是否可用或是否可以安装,因为我不是管理员/所有者,并且由于权限问题无法自己安装),我在如何实现这些功能的文档中没有找到这些模块。。。如果可能的话,我确实希望避免使用命令行命令,但如果这是创建此命令的最后手段,则不希望使用命令行命令 <?php // The certificate password $passphrase = "some ran

以下代码在perl中创建自签名证书的等效示例是什么

我所有可用的是Crypt::OpenSSL::RSA(如果有其他模块,请告诉我,以便我可以验证它是否可用或是否可以安装,因为我不是管理员/所有者,并且由于权限问题无法自己安装),我在如何实现这些功能的文档中没有找到这些模块。。。如果可能的话,我确实希望避免使用命令行命令,但如果这是创建此命令的最后手段,则不希望使用命令行命令

<?php
// The certificate password
$passphrase = "some random password";

// Fill in data for the distinguished name to be used in the cert
// You must change the values of these keys to match your name and
// company, or more precisely, the name and company of the person/site
// that you are generating the certificate for.
// For SSL certificates, the commonName is usually the domain name of
// that will be using the certificate, but for S/MIME certificates,
// the commonName will be the name of the individual who will use the
// certificate.
$certificateInfo = array(
    "countryName" => "UK",
    "stateOrProvinceName" => "England",
    "localityName" => "London",
    "organizationName" => "blabla",
    "organizationalUnitName" => "Bla bla Developer's Team",
    "commonName" => "blabla.com",
    "emailAddress" => "support@blabla.com"
);

$configargs = array(
    'digest_alg' => 'sha1',
    'private_key_bits' => 1024,
    'private_key_type' => OPENSSL_KEYTYPE_RSA,
    'encrypt_key' => true
    );

// Generate a new private (and public) key pair
$privkey = null;

// Generate a certificate signing request
$csr = openssl_csr_new($certificateInfo, $privkey);

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

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

大多数Perl模块,包括您找到的常见Crypt::OpenSSL::RSA模块,都只是围绕
OpenSSL
命令的包装器

所以,我建议你先考虑一下你需要的数据,以及如何在命令行上完成。这里有一些非常好的例子

然后,如果您想从Perl执行此操作,可以调整or from以包含所需的值和设置

另外,还有一个名为的Perl脚本,它包含在每个OpenSSL安装中:这也是一个很好的例子,可以根据您的需要对其进行调整。(在我的基于Debian的服务器上,它安装在
/usr/lib/ssl/misc/CA.pl
,但可能有所不同。)


祝你好运

试穿一下。我想这应该能满足你的需要。

你可以试试,它似乎或多或少能满足你的需要。您可能需要首先通过其他方式生成密钥对,可能是通过Crypt::OpenSSL::RSA。

如果您在使用第三方模块时遇到问题,您可能会发现这样的用法:@Ether您好,谢谢您的回复,这不是问题,我希望避免使用非默认模块(意味着perl默认安装中没有的模块)仅此而已,但根据模块的不同,即使不需要安装,它也可能可用,我知道这一点。例如,我列出的模块不是预装的。感谢您的回答,但我没有考虑制作或更改现有的模块,我正在寻找一个现成的模块,我知道如何从命令行和kno执行此操作w如何从perl调用命令,但处理所有错误(例如错误安装openssl、错误使用参数、用户输入、阻止用户使用它等等)这可能会出现,这将是一个痛苦,因此,我期待着找到一个现成的一个,否则我可能会坚持我目前拥有的…你可以发布一个样本,它做什么,上面所述的,因为从文件它似乎没有这样做。对不起,我没有示例代码,没有时间给你写一个。但你正在使用的所有方法,我都是n您的php示例也由OpenCA::OpenSSL提供。模块ist仍然保持不变(上次更新日期为2010年4月3日/Crypt::OpenSSL::CA的上次更新日期为2008年9月30日)。生成密钥对:genKey(),生成CertRequest:genReq(),自签名证书:genCert()。没有生成它们的问题是附加信息:)在PDO上没有任何文档记录,也没有我已经查看过的文档,因此我没有拿起它,这就是为什么我要求你举出一个例子,用这些附加信息创建证书,因为我找不到任何相关信息。