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--SKIPIF--
8<?php if (OPENSSL_VERSION_NUMBER < 0x10000000) die("skip Output requires OpenSSL 1.0");
9?>
10--FILE--
11<?php
12include 'CertificateGenerator.inc';
13$certificateGenerator = new CertificateGenerator();
14$certificateGenerator->saveCaCert(__DIR__ . "/san-cert.pem");
15
16$cert = "file://" . __DIR__ . "/cert.crt";
17$bert = "file://" . __DIR__ . "/bug41033.pem";
18$sert = "file://" . __DIR__ . "/san-cert.pem";
19$cpca = __DIR__ . "/san-cert.pem";
20$utfl = __DIR__ . "/sni_server_uk.pem";
21$rcrt = openssl_x509_read($cert);
22
23/*  int openssl_x509_checkpurpose ( mixed $x509cert , int $purpose);   */
24var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_SSL_CLIENT));
25var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_SSL_SERVER));
26var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_NS_SSL_SERVER));
27var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_SMIME_SIGN));
28var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_SMIME_ENCRYPT));
29var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_CRL_SIGN));
30var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_ANY));
31var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_SSL_CLIENT));
32var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_SSL_SERVER));
33var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_NS_SSL_SERVER));
34var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_SMIME_SIGN));
35var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_SMIME_ENCRYPT));
36var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_CRL_SIGN));
37var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_ANY));
38var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_SSL_CLIENT));
39var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_SSL_SERVER));
40var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_NS_SSL_SERVER));
41var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_SMIME_SIGN));
42var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_SMIME_ENCRYPT));
43var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_CRL_SIGN));
44var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_ANY));
45
46/* int openssl_x509_checkpurpose ( mixed $x509cert , int $purpose [, array $cainfo = array() ] ); */
47var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_SSL_CLIENT, array($cpca)));
48var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_SSL_SERVER, array($cpca)));
49var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_NS_SSL_SERVER, array($cpca)));
50var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_SMIME_SIGN, array($cpca)));
51var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_SMIME_ENCRYPT, array($cpca)));
52var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_CRL_SIGN, array($cpca)));
53var_dump(openssl_x509_checkpurpose($rcrt, X509_PURPOSE_ANY, array($cpca)));
54var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_SSL_CLIENT, array($cpca)));
55var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_SSL_SERVER, array($cpca)));
56var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_NS_SSL_SERVER, array($cpca)));
57var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_SMIME_SIGN, array($cpca)));
58var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_SMIME_ENCRYPT, array($cpca)));
59var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_CRL_SIGN, array($cpca)));
60var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_ANY, array($cpca)));
61var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_SSL_CLIENT, array($cpca)));
62var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_SSL_SERVER, array($cpca)));
63var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_NS_SSL_SERVER, array($cpca)));
64var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_SMIME_SIGN, array($cpca)));
65var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_SMIME_ENCRYPT, array($cpca)));
66var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_CRL_SIGN, array($cpca)));
67var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_ANY, array($cpca)));
68
69/* int openssl_x509_checkpurpose ( mixed $x509cert , int $purpose [, array $cainfo = array() [, string $untrustedfile ]] ); function */
70var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_SSL_CLIENT, array($cpca), $utfl));
71var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_SSL_SERVER, array($cpca), $utfl));
72var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_NS_SSL_SERVER, array($cpca), $utfl));
73var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_SMIME_SIGN, array($cpca), $utfl));
74var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_SMIME_ENCRYPT, array($cpca), $utfl));
75var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_CRL_SIGN, array($cpca), $utfl));
76var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_ANY, array($cpca), $utfl));
77var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_SSL_CLIENT, array($cpca), $utfl));
78var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_SSL_SERVER, array($cpca), $utfl));
79var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_NS_SSL_SERVER, array($cpca), $utfl));
80var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_SMIME_SIGN, array($cpca), $utfl));
81var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_SMIME_ENCRYPT, array($cpca), $utfl));
82var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_CRL_SIGN, array($cpca), $utfl));
83var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_ANY, array($cpca), $utfl));
84var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_SSL_CLIENT, array($cpca), $utfl));
85var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_SSL_SERVER, array($cpca), $utfl));
86var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_NS_SSL_SERVER, array($cpca), $utfl));
87var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_SMIME_SIGN, array($cpca), $utfl));
88var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_SMIME_ENCRYPT, array($cpca), $utfl));
89var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_CRL_SIGN, array($cpca), $utfl));
90var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_ANY, array($cpca), $utfl));
91?>
92--CLEAN--
93<?php
94@unlink(__DIR__ . "/san-cert.pem");
95?>
96--EXPECT--
97bool(false)
98bool(false)
99bool(false)
100bool(false)
101bool(false)
102bool(false)
103bool(false)
104int(-1)
105int(-1)
106int(-1)
107int(-1)
108int(-1)
109int(-1)
110int(-1)
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)
124bool(false)
125int(-1)
126int(-1)
127int(-1)
128int(-1)
129int(-1)
130int(-1)
131int(-1)
132bool(true)
133bool(true)
134bool(true)
135bool(true)
136bool(true)
137bool(true)
138bool(true)
139bool(false)
140bool(false)
141bool(false)
142bool(false)
143bool(false)
144bool(false)
145bool(false)
146int(-1)
147int(-1)
148int(-1)
149int(-1)
150int(-1)
151int(-1)
152int(-1)
153bool(true)
154bool(true)
155bool(true)
156bool(true)
157bool(true)
158bool(true)
159bool(true)
160