1--TEST--
2int openssl_x509_checkpurpose ( mixed $x509cert , int $purpose [, array $cainfo = array() [, string $untrustedfile ]] ) function
3--CREDITS--
4marcosptf - <marcosptf@yahoo.com.br>
5--SKIPIF--
6<?php if (!extension_loaded("openssl")) print "skip";
7if (OPENSSL_VERSION_NUMBER < 0x10000000) die("skip Output requires OpenSSL 1.0");
8?>
9--FILE--
10<?php
11include 'CertificateGenerator.inc';
12$certificateGenerator = new CertificateGenerator();
13$certificateGenerator->saveCaCert(__DIR__ . "/san-cert.pem");
14
15$cert = "file://" . __DIR__ . "/cert.crt";
16$bert = "file://" . __DIR__ . "/bug41033.pem";
17$sert = "file://" . __DIR__ . "/san-cert.pem";
18$cpca = __DIR__ . "/san-cert.pem";
19$utfl = __DIR__ . "/sni_server_uk.pem";
20$rcrt = openssl_x509_read($cert);
21
22/*  int openssl_x509_checkpurpose ( mixed $x509cert , int $purpose);   */
23var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_SSL_CLIENT));
24var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_SSL_SERVER));
25var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_NS_SSL_SERVER));
26var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_SMIME_SIGN));
27var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_SMIME_ENCRYPT));
28var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_CRL_SIGN));
29var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_ANY));
30var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_SSL_CLIENT));
31var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_SSL_SERVER));
32var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_NS_SSL_SERVER));
33var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_SMIME_SIGN));
34var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_SMIME_ENCRYPT));
35var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_CRL_SIGN));
36var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_ANY));
37var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_SSL_CLIENT));
38var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_SSL_SERVER));
39var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_NS_SSL_SERVER));
40var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_SMIME_SIGN));
41var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_SMIME_ENCRYPT));
42var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_CRL_SIGN));
43var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_ANY));
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)));
67
68/* int openssl_x509_checkpurpose ( mixed $x509cert , int $purpose [, array $cainfo = array() [, string $untrustedfile ]] ); function */
69var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_SSL_CLIENT, array($cpca), $utfl));
70var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_SSL_SERVER, array($cpca), $utfl));
71var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_NS_SSL_SERVER, array($cpca), $utfl));
72var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_SMIME_SIGN, array($cpca), $utfl));
73var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_SMIME_ENCRYPT, array($cpca), $utfl));
74var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_CRL_SIGN, array($cpca), $utfl));
75var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_ANY, array($cpca), $utfl));
76var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_SSL_CLIENT, array($cpca), $utfl));
77var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_SSL_SERVER, array($cpca), $utfl));
78var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_NS_SSL_SERVER, array($cpca), $utfl));
79var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_SMIME_SIGN, array($cpca), $utfl));
80var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_SMIME_ENCRYPT, array($cpca), $utfl));
81var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_CRL_SIGN, array($cpca), $utfl));
82var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_ANY, array($cpca), $utfl));
83var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_SSL_CLIENT, array($cpca), $utfl));
84var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_SSL_SERVER, array($cpca), $utfl));
85var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_NS_SSL_SERVER, array($cpca), $utfl));
86var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_SMIME_SIGN, array($cpca), $utfl));
87var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_SMIME_ENCRYPT, array($cpca), $utfl));
88var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_CRL_SIGN, array($cpca), $utfl));
89var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_ANY, array($cpca), $utfl));
90?>
91--CLEAN--
92<?php
93@unlink(__DIR__ . "/san-cert.pem");
94?>
95--EXPECT--
96bool(false)
97bool(false)
98bool(false)
99bool(false)
100bool(false)
101bool(false)
102bool(false)
103int(-1)
104int(-1)
105int(-1)
106int(-1)
107int(-1)
108int(-1)
109int(-1)
110bool(false)
111bool(false)
112bool(false)
113bool(false)
114bool(false)
115bool(false)
116bool(false)
117bool(false)
118bool(false)
119bool(false)
120bool(false)
121bool(false)
122bool(false)
123bool(false)
124int(-1)
125int(-1)
126int(-1)
127int(-1)
128int(-1)
129int(-1)
130int(-1)
131bool(true)
132bool(true)
133bool(true)
134bool(true)
135bool(true)
136bool(true)
137bool(true)
138bool(false)
139bool(false)
140bool(false)
141bool(false)
142bool(false)
143bool(false)
144bool(false)
145int(-1)
146int(-1)
147int(-1)
148int(-1)
149int(-1)
150int(-1)
151int(-1)
152bool(true)
153bool(true)
154bool(true)
155bool(true)
156bool(true)
157bool(true)
158bool(true)
159