1

自己署名証明書を作成するための次のコードの 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);
?>
4

3 に答える 3

0

Crypt::OpenSSL::CAを試すことができます。最初の例は、多かれ少なかれあなたが望むことをしているようです。おそらくCrypt::OpenSSL::RSAを介して、他の方法で最初にキーペアを生成する必要があるかもしれません。

于 2010-07-08T13:34:24.003 に答える
0

あなたが見つけた一般的な Crypt::OpenSSL::RSA を含む Perl モジュールのほとんどは、単にopensslコマンドのラッパーです。

したがって、最初に必要なデータと、コマンドラインでのデータの処理方法を検討することをお勧めします。素晴らしい例チュートリアルがいくつかあります。

次に、Perl からこれを実行する場合は、Crypt::OpenSSL::RSAまたはOpenCA::OpenSSL (OpenSSL コマンドを統合するための別の一般的なモジュール)のサンプル コードを微調整して、必要な値と設定を含めることができます。

別の方法として、すべての OpenSSL インストールに含まれているCA.plというPerl スクリプトがあります。これは、例を取り上げてニーズに合わせて微調整するのにも適しています。(私の Debian ベースのサーバーでは、にインストールされて/usr/lib/ssl/misc/CA.plいますが、異なる場合があります。)

幸運を!

于 2010-07-02T14:50:04.383 に答える
0

OpenCA::OpenSSLを試してみてください。これはあなたが必要とすることをするべきだと思います。

于 2010-07-08T12:16:59.657 に答える