File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,10 @@ $envs = [
2121 'ATLAS_TLS12 ' ,
2222 'ATLAS_SRV_TLS12 ' ,
2323];
24+ $ x509Envs = [
25+ 'ATLAS_X509 ' ,
26+ 'ATLAS_X509_DEV ' ,
27+ ];
2428
2529$ command = new \MongoDB \Driver \Command (['ping ' => 1 ]);
2630$ query = new \MongoDB \Driver \Query ([]);
@@ -43,6 +47,34 @@ foreach ($envs as $env) {
4347 echo "FAIL: " , $ e ->getMessage (), "\n" ;
4448 }
4549}
50+
51+ foreach ($ x509Envs as $ env ) {
52+ echo $ env , ': ' ;
53+ $ uri = getenv ($ env );
54+ $ cert = getenv ($ env . '_CERT_BASE64 ' );
55+
56+ if (! is_string ($ uri )) {
57+ echo "FAIL: env var is undefined \n" ;
58+ continue ;
59+ }
60+
61+ if (! is_string ($ cert )) {
62+ echo "FAIL: cert env var is undefined \n" ;
63+ continue ;
64+ }
65+
66+ file_put_contents ('/tmp/cert.pem ' , base64_decode ($ cert ));
67+
68+ try {
69+ $ m = new \MongoDB \Driver \Manager ($ uri . '&tlsCertificateKeyFile=/tmp/cert.pem ' );
70+ $ m ->executeCommand ('admin ' , $ command );
71+ iterator_to_array ($ m ->executeQuery ('test.test ' , $ query ));
72+ echo "PASS \n" ;
73+ } catch (Exception $ e ) {
74+ echo "FAIL: " , $ e ->getMessage (), "\n" ;
75+ }
76+ }
77+
4678?>
4779===DONE===
4880<?php exit (0 ); ?>
@@ -59,4 +91,6 @@ ATLAS_TLS11: PASS
5991ATLAS_SRV_TLS11: PASS
6092ATLAS_TLS12: PASS
6193ATLAS_SRV_TLS12: PASS
94+ ATLAS_X509: PASS
95+ ATLAS_X509_DEV: PASS
6296===DONE===
You can’t perform that action at this time.
0 commit comments