**わかりました。この問題は、Linux サーバーでの openssl のセットアップと、カスタム openssl.cnf ファイルの適切なセットアップ方法に関連する問題であることが明らかになりました。複雑なものは探していませんが、Web サービスへの認証用の自己署名クライアント証明書を作成できるフロントエンドが必要です。そのため、CA を使用してクライアント企業用の中間 CA を作成し、セキュアなインターフェイスを使用して従業員にクライアント証明書を発行できるようにする必要があります。ログインは、特定の中間 CA に属しているかどうか、および証明書または中間 CA が取り消されていないことに基づいています。
不思議に思っている人のために、自己署名証明書を使用できます。これは、サーバーがユーザーを認証するためにのみ使用され、発行されたので信頼できるためです。また、スタートアップが商用サービスを通じて中間 CA としての地位を確立するには、費用がかかりすぎます。マイクロソフトにはできますが、私たちにはできません。当社の Web サーバー自体は、CA 署名付き証明書を使用しています。
この種のものを設定するためのphpコードは簡単ですが、opensslを適切に設定する方法はそうではありません。ネットでいくつかの異なる例を試しましたが、どれも私の設定では機能しないようで、すべて異なっているようです。1 つのボックスは Centos 6.2 の新規インストールでしたが、まだエラーが発生しています。
エラーなしでこれらのphpライブラリを使用できるように、openssl、apache2、およびphpをセットアップするための適切な方向を誰かが教えてくれますか? 私たちの仮想サーバーは debian スクイーズを使用しており、インストールされているソフトウェアを完全に制御できます。
ありがとう。
open_pkey_new()は error:0E06D06C:configuration file routine:NCONF_get_string:no value などのエラーを返します。それでも、openssl.cnf ファイルへのパスを渡しているので、なぜこの問題がまだ発生しているのかわかりません。ここに私の関連コードがあります
<?php
$cwd=getcwd();
$distname= array(
"countryName" => "CA",
"stateOrProvinceName" => "Ontario",
"localityName" => "Toronto",
"organizationName" => "G4 Apps",
"organizationalUnitName" => "Development",
"commonName" => "Mark Lane",
"emailAddress" => "nobody at gmail.com"
);
$password = 'seanix';
$cacert_location=$cwd."/certs/CA/g4CA.crt";
$cakey_location=$cwd."/certs/CA/g4CA.key";
$cnf=$cwd.'/certs/myopenssl.cnf';
$configArgs = array(
'config' =>$cnf
);
?>
キーを作成する関数は次のとおりです。
<?php
function makekey($password,$configArgs) {
$key= openssl_pkey_new($configArgs);
//print_r($configArgs);
openssl_pkey_export($key, $pkeyout,$password);
if (($e=openssl_error_string()) ==false) return $pkeyout;
else {
do {
echo $e . "<BR>";
} while($e=openssl_error_string());
return -1;
}
}
?>
構成ファイルへの相対パスも試しましたが、まだ機能しません。ホストプロバイダーのSSL設定のようです。ローカル仮想マシンに切り替え、生成するキーを取得しましたが、csr の作成時に同じエラーが発生します。
エラー: 0E06D06C: 構成ファイル ルーチン: NCONF_get_string: 値なし
<?php
function newcsr($distname,$key,$configArgs) {
$csr=openssl_csr_new($distname,$key,$configArgs);
openssl_csr_export($csr, $csrout);
if (($e=openssl_error_string()) ==false) return $csrout;
else {
do {
echo $e . "<BR>";
} while($e=openssl_error_string());
return -1;
}
}
?>
openssl.confこれは openssl.cnf のエラーのように見えるので、ファイルを含めました。
HOME = .
RANDFILE = $ENV::HOME/.rnd
oid_section = new_oids
[ new_oids ]
tsa_policy1 = 1.2.3.4.1
tsa_policy2 = 1.2.3.4.5.6
tsa_policy3 = 1.2.3.4.5.7
####################################################################
[ ca ]
default_ca = g4CA
####################################################################
[ g4CA ]
dir = /home/g4apps/secure.g4apps.com/generator/certs
certs = $dir/
crl_dir = $dir/crl
database = $dir/index.txt
new_certs_dir = $dir/newcerts
certificate = $dir/CA/g4CA.crt
serial = $dir/serial
crlnumber = $dir/crlnumber
crl = $dir/CA/g4CA.crl
private_key = $dir/CA/g4CA.key
RANDFILE = $dir/private/.rand
x509_extensions = usr_cert
name_opt = ca_default
cert_opt = ca_default
default_days = 365 # how long to certify for
default_crl_days= 30 # how long before next CRL
default_md = default # use public key default MD
preserve = no # keep passed DN ordering
policy = policy_match
[ policy_match ]
countryName = match
stateOrProvinceName = match
organizationName = match
organizationalUnitName = optional
commonName = supplied
emailAddress = optional
[ policy_anything ]
countryName = optional
stateOrProvinceName = optional
localityName = optional
organizationName = optional
organizationalUnitName = optional
commonName = supplied
emailAddress = optional
####################################################################
[ req ]
default_bits = 2048
default_md = md5
default_keyfile = privkey.pem
distinguished_name = req_distinguished_name
attributes = req_attributes
x509_extensions = v3_ca # The extentions to add to the self signed cert
string_mask = utf8only
[ req_distinguished_name ]
countryName = Country Name (2 letter code)
countryName_default = CA
countryName_min = 2
countryName_max = 2
stateOrProvinceName = State or Province Name (full name)
stateOrProvinceName_default = ON
localityName = Locality Name (eg, city)
localityName_default = Toronto
0.organizationName = Organization Name (eg, company)
0.organizationName_default = G4 Apps
organizationalUnitName = Organizational Unit Name (eg, section)
commonName = Common Name (eg, your name or your server\'s hostname)
commonName_max = 64
emailAddress = Email Address
emailAddress_default = lmlane@gmail.com
emailAddress_max = 64
[ req_attributes ]
challengePassword = A challenge password
challengePassword_min = 4
challengePassword_max = 20
unstructuredName = An optional company name
[ usr_cert ]
nsComment = "OpenSSL Generated Certificate"
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid,issuer
[ v3_req ]
basicConstraints = CA:FALSE
keyUsage = nonRepudiation, digitalSignature, keyEncipherment
[ v3_ca ]
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid:always,issuer
basicConstraints = CA:true
[ crl_ext ]
authorityKeyIdentifier=keyid:always
[ proxy_cert_ext ]
basicConstraints=CA:FALSE
nsComment = "OpenSSL Generated Certificate"
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid,issuer
proxyCertInfo=critical,language:id-ppl-anyLanguage,pathlen:3,policy:foo
####################################################################
[ tsa ]
default_tsa = tsa_config1
[ tsa_config1 ]
dir = ./demoCA
serial = $dir/tsaserial
crypto_device = builtin
signer_cert = $dir/tsacert.pem
certs = $dir/cacert.pem
signer_key = $dir/private/tsakey.pem
default_policy = tsa_policy1
other_policies = tsa_policy2, tsa_policy3
digests = md5, sha1
accuracy = secs:1, millisecs:500, microsecs:100
clock_precision_digits = 0
ordering = yes
tsa_name = yes
ess_cert_id_chain = no
スタックトレースstrace php getkeystore.php &> stack.trace