Action:
Method:
Method:
Method:
Method:
<?php include('File/X509.php'); $x509 = new File_X509(); $cert = $x509->loadX509('...'); // see google.crt print_r($cert); print_r($x509->getDNProp('CN')); print_r($x509->getDN()); print_r($x509->getIssuerDNProp('CN')); echo $x509->getPublicKey(); echo $x509->getDN(true); echo $x509->getIssuerDN(true); print_r($x509->getIssuerDN()); include('File/X509.php'); $x509 = new File_X509(); $x509->loadCA('...'); // see signer.crt $cert = $x509->loadX509('...'); // see google.crt// see selfsigned.crt echo $x509->validateSignature() ? 'valid' : 'invalid'; echo $x509->validateSignature(false) ? 'valid' : 'invalid'; // try it with "http://www.bing.com/search?q=phpseclib" too echo $x509->validateURL('https://www.google.com/#q=phpseclib') ? 'valid' : 'invalid'; echo $x509->validateDate() ? 'valid' : 'invalid'; echo $x509->validateDate(strtotime('January 1, 2001')) ? 'valid' : 'invalid'; include('File/X509.php'); include('Crypt/RSA.php'); $privKey = new Crypt_RSA(); extract($privKey->createKey()); $privKey->loadKey($privatekey); $x509 = new File_X509(); $x509->setPrivateKey($privKey); $x509->setDNProp('id-at-organizationName', 'phpseclib demo cert'); $csr = $x509->signCSR(); echo $x509->saveCSR($csr); include('File/X509.php'); $x509 = new File_X509(); $csr = $x509->loadCSR('...'); // see csr.csr print_r($csr); //echo $x509->validateSignature() ? 'valid' : 'invalid'; print_r($x509->getDNProp('O')); print_r($x509->getDN()); echo $x509->getDN(true); echo $x509->getPublicKey(); include('File/X509.php'); $x509 = new File_X509(); $spkac = $x509->loadSPKAC('...'); // see spkac.spkac print_r($spkac); //echo $x509->validateSignature() ? 'valid' : 'invalid'; ?>
(see phpseclib: X.509: Decoder to try phpseclib's X.509 decoder with your own certificates)
$cert
:
-----BEGIN PUBLIC KEY----- MIGJAoGBAN63JkOmmYXNOKcVCbnPD8nDVYyI7oyNKCckSypeoNgW+mEYS89tYIDTNUAycsCPEtjl To+5svbZFV5ahjGjuoaqa8jZcYzMzScTHp1CXTj2p6zv+mLzGIHUJEZ/AXd8xiqJFJm7mDkdqBn7 OQBEfRuUangtaa3Aeiz60NogEpjTAgMBAAE= -----END PUBLIC KEY-----
$prop
:$dn
:
-----BEGIN PUBLIC KEY----- MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDetyZDppmFzTinFQm5zw/Jw1WM iO6MjSgnJEsqXqDYFvphGEvPbWCA0zVAMnLAjxLY5U6PubL22RVeWoYxo7qGqmvI 2XGMzM0nEx6dQl049qes7/pi8xiB1CRGfwF3fMYqiRSZu5g5HagZ+zkARH0blGp4 LWmtwHos+tDaIBKY0wIDAQAB -----END PUBLIC KEY-----
$prop
:
Thawte SGC CA
$dn
:
An array is returned because each distinguished name property can (in theory) have multiple values
Valid property names are enumerated upon at Distinguished Property Names.
-----BEGIN CERTIFICATE REQUEST----- MIIBVjCBwgIAMB4xHDAaBgNVBAoME3BocHNlY2xpYiBkZW1vIGNlcnQwgZ0wCwYJKoZIhvcNAQEB A4GNADCBiQKBgQDF+1/N2DwvdkhoHsLq8LnH99AEGVOGpooSpbPCewbuZeqr/Djb9ySPar2PLySo Y+kB2QAbxUgpO/57IpWIabQ9jDFIznqLCcLzXKiKOWnMv4KMf55yJ6pwlqoTbUPgyQ67CRAfjcaD W9VQ/TzdKahdxLFPBAEIEpEX23YpLhTLNQIDAQABMAsGCSqGSIb3DQEBBQOBgQALjJE4OygjvLm0 rzFyMPvAo7Ux6z5qTOi//HQzzmjNun7MV09GTfZgcYeWvuLosJXcn7CPALF5FqHWePs98WioTA7K WsvdZzm+yJ5UcmzdJ/Jq9X8o1KTsMELN0SQwiNk502a1wbiXotF4OgCsjSdno96PCV9VSF4w69HM 1eXfvg== -----END CERTIFICATE REQUEST-----
$csr:
-----BEGIN PUBLIC KEY----- MIGJAoGBAKUAZcMKDkb0malJqS+aaAAy1rEQceebS7N2KvGX25EqPJx3rWz5zrpCD/zZcZ95/zBj r7F0GvTS4rC0OlJsi8iV11VvBZ+qQkCKZ8oIzW6HILOro+O1BFw8DMJXyyj2fNDO4ZjKYWWeFG/y AXtEuSje+2MWLxShinzDVymVsdf/AgMBAAE= -----END PUBLIC KEY-----
$prop
:
phpseclib demo cert
$prop:
-----BEGIN PUBLIC KEY----- MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQClAGXDCg5G9JmpSakvmmgAMtax EHHnm0uzdirxl9uRKjycd61s+c66Qg/82XGfef8wY6+xdBr00uKwtDpSbIvIlddV bwWfqkJAimfKCM1uhyCzq6PjtQRcPAzCV8so9nzQzuGYymFlnhRv8gF7RLko3vtj Fi8UoYp8w1cplbHX/wIDAQAB -----END PUBLIC KEY-----
$spkac: