1--TEST-- 2int openssl_x509_checkpurpose ( mixed $x509cert , int $purpose [, array $cainfo = array() [, string $untrustedfile ]] ) function 3--CREDITS-- 4marcosptf - <marcosptf@yahoo.com.br> 5--EXTENSIONS-- 6openssl 7--FILE-- 8<?php 9include 'CertificateGenerator.inc'; 10$certificateGenerator = new CertificateGenerator(); 11$certificateGenerator->saveCaCert(__DIR__ . "/san-cert.pem"); 12 13$cert = "file://" . __DIR__ . "/cert.crt"; 14$bert = "file://" . __DIR__ . "/bug41033.pem"; 15$sert = "file://" . __DIR__ . "/san-cert.pem"; 16$cpca = __DIR__ . "/san-cert.pem"; 17$utfl = __DIR__ . "/sni_server_uk.pem"; 18$rcrt = openssl_x509_read($cert); 19 20/* int openssl_x509_checkpurpose ( mixed $x509cert , int $purpose); */ 21var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_SSL_CLIENT)); 22var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_SSL_SERVER)); 23var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_NS_SSL_SERVER)); 24var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_SMIME_SIGN)); 25var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_SMIME_ENCRYPT)); 26var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_CRL_SIGN)); 27var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_ANY)); 28var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_SSL_CLIENT)); 29var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_SSL_SERVER)); 30var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_NS_SSL_SERVER)); 31var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_SMIME_SIGN)); 32var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_SMIME_ENCRYPT)); 33var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_CRL_SIGN)); 34var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_ANY)); 35var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_SSL_CLIENT)); 36var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_SSL_SERVER)); 37var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_NS_SSL_SERVER)); 38var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_SMIME_SIGN)); 39var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_SMIME_ENCRYPT)); 40var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_CRL_SIGN)); 41var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_ANY)); 42var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_OCSP_HELPER)); 43var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_TIMESTAMP_SIGN)); 44 45/* int openssl_x509_checkpurpose ( mixed $x509cert , int $purpose [, array $cainfo = array() ] ); */ 46var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_SSL_CLIENT, array($cpca))); 47var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_SSL_SERVER, array($cpca))); 48var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_NS_SSL_SERVER, array($cpca))); 49var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_SMIME_SIGN, array($cpca))); 50var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_SMIME_ENCRYPT, array($cpca))); 51var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_CRL_SIGN, array($cpca))); 52var_dump(openssl_x509_checkpurpose($rcrt, X509_PURPOSE_ANY, array($cpca))); 53var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_SSL_CLIENT, array($cpca))); 54var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_SSL_SERVER, array($cpca))); 55var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_NS_SSL_SERVER, array($cpca))); 56var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_SMIME_SIGN, array($cpca))); 57var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_SMIME_ENCRYPT, array($cpca))); 58var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_CRL_SIGN, array($cpca))); 59var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_ANY, array($cpca))); 60var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_SSL_CLIENT, array($cpca))); 61var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_SSL_SERVER, array($cpca))); 62var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_NS_SSL_SERVER, array($cpca))); 63var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_SMIME_SIGN, array($cpca))); 64var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_SMIME_ENCRYPT, array($cpca))); 65var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_CRL_SIGN, array($cpca))); 66var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_ANY, array($cpca))); 67var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_OCSP_HELPER, array($cpca))); 68var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_TIMESTAMP_SIGN, array($cpca))); 69 70/* int openssl_x509_checkpurpose ( mixed $x509cert , int $purpose [, array $cainfo = array() [, string $untrustedfile ]] ); function */ 71var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_SSL_CLIENT, array($cpca), $utfl)); 72var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_SSL_SERVER, array($cpca), $utfl)); 73var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_NS_SSL_SERVER, array($cpca), $utfl)); 74var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_SMIME_SIGN, array($cpca), $utfl)); 75var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_SMIME_ENCRYPT, array($cpca), $utfl)); 76var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_CRL_SIGN, array($cpca), $utfl)); 77var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_ANY, array($cpca), $utfl)); 78var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_SSL_CLIENT, array($cpca), $utfl)); 79var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_SSL_SERVER, array($cpca), $utfl)); 80var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_NS_SSL_SERVER, array($cpca), $utfl)); 81var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_SMIME_SIGN, array($cpca), $utfl)); 82var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_SMIME_ENCRYPT, array($cpca), $utfl)); 83var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_CRL_SIGN, array($cpca), $utfl)); 84var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_ANY, array($cpca), $utfl)); 85var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_SSL_CLIENT, array($cpca), $utfl)); 86var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_SSL_SERVER, array($cpca), $utfl)); 87var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_NS_SSL_SERVER, array($cpca), $utfl)); 88var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_SMIME_SIGN, array($cpca), $utfl)); 89var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_SMIME_ENCRYPT, array($cpca), $utfl)); 90var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_CRL_SIGN, array($cpca), $utfl)); 91var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_ANY, array($cpca), $utfl)); 92var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_OCSP_HELPER, array($cpca), $utfl)); 93var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_TIMESTAMP_SIGN, array($cpca), $utfl)); 94?> 95--CLEAN-- 96<?php 97@unlink(__DIR__ . "/san-cert.pem"); 98?> 99--EXPECT-- 100bool(false) 101bool(false) 102bool(false) 103bool(false) 104bool(false) 105bool(false) 106bool(false) 107int(-1) 108int(-1) 109int(-1) 110int(-1) 111int(-1) 112int(-1) 113int(-1) 114bool(false) 115bool(false) 116bool(false) 117bool(false) 118bool(false) 119bool(false) 120bool(false) 121bool(false) 122bool(false) 123bool(false) 124bool(false) 125bool(false) 126bool(false) 127bool(false) 128bool(false) 129bool(false) 130int(-1) 131int(-1) 132int(-1) 133int(-1) 134int(-1) 135int(-1) 136int(-1) 137bool(true) 138bool(true) 139bool(true) 140bool(true) 141bool(true) 142bool(true) 143bool(true) 144bool(true) 145bool(false) 146bool(false) 147bool(false) 148bool(false) 149bool(false) 150bool(false) 151bool(false) 152bool(false) 153int(-1) 154int(-1) 155int(-1) 156int(-1) 157int(-1) 158int(-1) 159int(-1) 160bool(true) 161bool(true) 162bool(true) 163bool(true) 164bool(true) 165bool(true) 166bool(true) 167bool(true) 168bool(false) 169