ssl: match private key with certificat | using php & phpseclib -
ssl: match private key with certificat | using php & phpseclib -
situation: have server-admin-panel, user should able upload private key / certificate / ca-certificate ( / csr) ssl website protection.
the uploaded info this:
private key =
-----begin rsa private key----- miiepqibaakcaqea3u+si24xgaqihnlcmcfefopmvaoezow3dpz7vexb6soliu0a [...] m9yqw2mv/ehnxth7pw85hjkazytxljvwixbeey9xx+gkqjuq1ghfgfe= -----end rsa private key----- certificate =
-----begin certificate----- miidfjccamigawibagieu6fngzalbgkqhkig9w0baquwgyexczajbgnvbaymakrf [...] oossauke596+wwm0xxdfot2t/d0lhvw1qvyfx0gzcrhwqq== -----end certificate----- problem: after uploading, need check, if cert / ca-cert match private key ( / csr), ensure, uploaded parts belong together.
i think i'm stuck. openssl check if output of next command matches each other. don't know how phpseclib.
openssl x509 -noout -modulus -in certificate.crt | openssl md5 openssl rsa -noout -modulus -in privatekey.key | openssl md5 openssl req -noout -modulus -in csr.csr | openssl md5 (i stick phpseclib, openssl not option)
thank very much!
something trick?:
$rsa = new crypt_rsa(); $rsa->loadkey(...); $pubkey1 = $rsa->getpublickey(); $x509 = new file_x509(); $x509->loadx509(...); $pubkey2 = $x509->getpublickey(); $csr = new file_x509(); $csr->loadcsr(...); $pubkey3 = $csr->getpublickey(); if (($pubkey1 == $pubkey2) && ($pubkey2 == $pubkey3)) { echo "they're equal"; } else { echo "they're not equal"; } php ssl phpseclib
Comments
Post a Comment