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
11$cert = "file://" . dirname(__FILE__) . "/cert.crt";
12$bert = "file://" . dirname(__FILE__) . "/bug41033.pem";
13$sert = "file://" . dirname(__FILE__) . "/san-cert.pem";
14$cpca = dirname(__FILE__) . "/san-ca.pem";
15$utfl = dirname(__FILE__) . "/sni_server_uk.pem";
16$rcrt = openssl_x509_read($cert);
17
18/*  int openssl_x509_checkpurpose ( mixed $x509cert , int $purpose);   */
19var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_SSL_CLIENT));
20var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_SSL_SERVER));
21var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_NS_SSL_SERVER));
22var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_SMIME_SIGN));
23var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_SMIME_ENCRYPT));
24var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_CRL_SIGN));
25var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_ANY));
26var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_SSL_CLIENT));
27var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_SSL_SERVER));
28var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_NS_SSL_SERVER));
29var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_SMIME_SIGN));
30var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_SMIME_ENCRYPT));
31var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_CRL_SIGN));
32var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_ANY));
33var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_SSL_CLIENT));
34var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_SSL_SERVER));
35var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_NS_SSL_SERVER));
36var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_SMIME_SIGN));
37var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_SMIME_ENCRYPT));
38var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_CRL_SIGN));
39var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_ANY));
40
41/* int openssl_x509_checkpurpose ( mixed $x509cert , int $purpose [, array $cainfo = array() ] ); */
42var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_SSL_CLIENT, array($cpca)));
43var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_SSL_SERVER, array($cpca)));
44var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_NS_SSL_SERVER, array($cpca)));
45var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_SMIME_SIGN, array($cpca)));
46var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_SMIME_ENCRYPT, array($cpca)));
47var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_CRL_SIGN, array($cpca)));
48var_dump(openssl_x509_checkpurpose($rcrt, X509_PURPOSE_ANY, array($cpca)));
49var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_SSL_CLIENT, array($cpca)));
50var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_SSL_SERVER, array($cpca)));
51var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_NS_SSL_SERVER, array($cpca)));
52var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_SMIME_SIGN, array($cpca)));
53var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_SMIME_ENCRYPT, array($cpca)));
54var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_CRL_SIGN, array($cpca)));
55var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_ANY, array($cpca)));
56var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_SSL_CLIENT, array($cpca)));
57var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_SSL_SERVER, array($cpca)));
58var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_NS_SSL_SERVER, array($cpca)));
59var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_SMIME_SIGN, array($cpca)));
60var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_SMIME_ENCRYPT, array($cpca)));
61var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_CRL_SIGN, array($cpca)));
62var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_ANY, array($cpca)));
63
64/* int openssl_x509_checkpurpose ( mixed $x509cert , int $purpose [, array $cainfo = array() [, string $untrustedfile ]] ); function */
65var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_SSL_CLIENT, array($cpca), $utfl));
66var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_SSL_SERVER, array($cpca), $utfl));
67var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_NS_SSL_SERVER, array($cpca), $utfl));
68var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_SMIME_SIGN, array($cpca), $utfl));
69var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_SMIME_ENCRYPT, array($cpca), $utfl));
70var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_CRL_SIGN, array($cpca), $utfl));
71var_dump(openssl_x509_checkpurpose($cert, X509_PURPOSE_ANY, array($cpca), $utfl));
72var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_SSL_CLIENT, array($cpca), $utfl));
73var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_SSL_SERVER, array($cpca), $utfl));
74var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_NS_SSL_SERVER, array($cpca), $utfl));
75var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_SMIME_SIGN, array($cpca), $utfl));
76var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_SMIME_ENCRYPT, array($cpca), $utfl));
77var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_CRL_SIGN, array($cpca), $utfl));
78var_dump(openssl_x509_checkpurpose($bert, X509_PURPOSE_ANY, array($cpca), $utfl));
79var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_SSL_CLIENT, array($cpca), $utfl));
80var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_SSL_SERVER, array($cpca), $utfl));
81var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_NS_SSL_SERVER, array($cpca), $utfl));
82var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_SMIME_SIGN, array($cpca), $utfl));
83var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_SMIME_ENCRYPT, array($cpca), $utfl));
84var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_CRL_SIGN, array($cpca), $utfl));
85var_dump(openssl_x509_checkpurpose($sert, X509_PURPOSE_ANY, array($cpca), $utfl));
86?>
87--EXPECT--
88bool(false)
89bool(false)
90bool(false)
91bool(false)
92bool(false)
93bool(false)
94bool(false)
95int(-1)
96int(-1)
97int(-1)
98int(-1)
99int(-1)
100int(-1)
101int(-1)
102bool(false)
103bool(false)
104bool(false)
105bool(false)
106bool(false)
107bool(false)
108bool(false)
109bool(false)
110bool(false)
111bool(false)
112bool(false)
113bool(false)
114bool(false)
115bool(false)
116int(-1)
117int(-1)
118int(-1)
119int(-1)
120int(-1)
121int(-1)
122int(-1)
123bool(true)
124bool(true)
125bool(true)
126bool(true)
127bool(true)
128bool(true)
129bool(true)
130bool(false)
131bool(false)
132bool(false)
133bool(false)
134bool(false)
135bool(false)
136bool(false)
137int(-1)
138int(-1)
139int(-1)
140int(-1)
141int(-1)
142int(-1)
143int(-1)
144bool(true)
145bool(true)
146bool(true)
147bool(true)
148bool(true)
149bool(true)
150bool(true)
151