ongoing new datepicker project
[openemr.git] / interface / usergroup / ssl_certificates_admin.php
blobced14bbdfb3bf07ef1f4c08fc2f65ebd9eb4da53
1 <?php
2 require_once("../globals.php");
3 require_once("../../library/create_ssl_certificate.php");
5 /********************************************************************************\
6 * Copyright (C) Visolve (vicareplus_engg@visolve.com) *
7 * *
8 * This program is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU General Public License *
10 * as published by the Free Software Foundation; either version 2 *
11 * of the License, or (at your option) any later version. *
12 * *
13 * This program is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU General Public License *
19 * along with this program; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21 ********************************************************************************/
24 * This page is used to setup https access to OpenEMR with client certificate authentication.
25 * If enabled, the browser must connect to OpenEMR using a client SSL certificate that is
26 * generated by OpenEMR. This page is used to create the Certificate Authority and
27 * Apache SSL server certificate.
30 /* This string contains any error messages if generating
31 * certificates fails.
33 $error_msg = "";
35 /* This function is called when the "Save Certificate Settings" button is clicked.
36 * Save the certificate settings to the file globals.php.
37 * The following form inputs are used:
38 * cakey_location - The path to the CA key file
39 * cacrt_location - The path to the CA certificate file
40 * clientCertValidity_hidden - Number of days client certificates are valid.
41 * isClientAuthenticationEnabled - Enable/disable client certificate authentication.
43 * Save these values to the following variables in globals.php:
44 * $certificate_authority_key
45 * $certificate_authority_crt
46 * $client_certificate_valid_in_days
47 * $is_client_ssl_enabled
49 * If an error occurs, set $error_msg to the appropriate string,
50 * which will be displayed later on below.
52 /*function save_certificate_settings() {
53 if($_POST['cakey_location']) { $Authority_key = formData('cakey_location','P',true) ; }
54 if($_POST['cacrt_location']) { $Authority_crt = formData('cacrt_location','P',true); }
55 if($_POST['clientCertValidity_hidden']) { $clientCertValidity = formData('clientCertValidity_hidden','P',true); }
56 if($_POST['isClientAuthenticationEnabled']) { $isClientAuthenticationEnabled = formData('isClientAuthenticationEnabled','P',true); }
58 if ($isClientAuthenticationEnabled == "Yes") {
59 $isClientAuthenticationEnabled = "true";
60 } else{
61 $isClientAuthenticationEnabled = "false";
64 global $error_msg;
66 if ($Authority_key != "" && !file_exists($Authority_key)) {
67 $error_msg .= xl('Error: the file does not exist', 'e') . ' ' . $Authority_key . '<br>';
70 if ($Authority_crt != "" && !file_exists($Authority_crt)) {
71 $error_msg .= xl('Error, the file does not exist', 'e') . ' ' . $Authority_crt . '<br>';
74 if ($error_msg != "") {
75 return;
78 $Authority_key = str_replace('\\\\', '/', $Authority_key);
79 $Authority_key = str_replace('\\', '/', $Authority_key);
80 $Authority_crt = str_replace('\\\\', '/', $Authority_crt);
81 $Authority_crt = str_replace('\\', '/', $Authority_crt);
83 // Read in the globals.php file
84 $globals_file = $GLOBALS['webserver_root'] . "/interface/globals.php";
85 $inputdata = file($globals_file) or die( xl('Could not read file','e')." ". $globals_file);
86 $outputdata = "";
88 $wrote_key = false;
89 $wrote_crt = false;
90 $wrote_enable = false;
91 $wrote_validity = false;
93 // Loop through each line in globals.php, replacing any certificate variables with the new settings.
95 foreach ($inputdata as $line) {
96 if ((strpos($line,"\$certificate_authority_key = \"")) !== false) {
97 $wrote_key = true;
98 $outputdata .= "\$certificate_authority_key = \"$Authority_key\";\n";
100 else if ((strpos($line,"\$certificate_authority_crt = \"")) !== false) {
101 $wrote_crt = true;
102 $outputdata .= "\$certificate_authority_crt = \"$Authority_crt\";\n";
104 else if ((strpos($line,"\$is_client_ssl_enabled = ")) !== false) {
105 $wrote_enable = true;
106 $outputdata .= "\$is_client_ssl_enabled = $isClientAuthenticationEnabled;\n";
108 else if ((strpos($line,"\$client_certificate_valid_in_days = \"")) !== false) {
109 $wrote_validity = true;
110 $outputdata .= "\$client_certificate_valid_in_days = \"$clientCertValidity\";\n";
112 else {
113 $outputdata .= $line;
116 if ($wrote_key === false || $wrote_crt === false ||
117 $wrote_enable === false || $wrote_validity === false) {
119 $outputdata .= "<?php\n";
121 if ($wrote_key === false) {
122 $outputdata .= "\$certificate_authority_key = \"$Authority_key\";\n";
124 if ($wrote_crt == false) {
125 $outputdata .= "\$certificate_authority_crt = \"$Authority_crt\";\n";
127 if ($wrote_enable === false) {
128 $outputdata .= "\$is_client_ssl_enabled = $isClientAuthenticationEnabled;\n";
130 if ($wrote_validity === false) {
131 $outputdata .= "\$client_certificate_valid_in_days = \"$clientCertValidity\";\n";
133 $outputdata .= "\n?>\n";
136 // Write the modified globals.php back to disk
137 $fd = @fopen($globals_file, 'w');
138 if ($fd === false) {
139 $error_msg .= xl('Error, unable to open file', 'e') . ' ' . $globals_file;
140 return;
142 fwrite($fd, $outputdata);
143 fclose($fd);
145 $GLOBALS['is_client_ssl_enabled'] = ($isClientAuthenticationEnabled == "true");
146 $GLOBALS['certificate_authority_crt'] = $Authority_crt;
147 $GLOBALS['certificate_authority_key'] = $Authority_key;
152 * Send an http reply so that the browser downloads the given file.
153 * Delete the file once the download is completed.
154 * @param $filename - The file to download.
155 * @param $filetype - The type of file.
157 function download_file($filename, $filetype) {
159 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
160 header("Cache-Control: private");
161 header("Content-Type: application/" . $filetype);
162 header("Content-Disposition: attachment; filename=" . basename($filename) . ";");
163 header("Content-Transfer-Encoding: binary");
164 header("Content-Length: " . filesize($filename));
165 readfile($filename);
166 exit;
167 flush();
168 @unlink($filename);
171 /* This function is called when the "Create Client Certificate" button is clicked.
172 * Create and download a client certificate, given the following form inputs:
173 * client_cert_user - The username to store in the certificate
174 * client_cert_email - The email to store in the certificate
175 * A temporary certificate will be written to /tmp/openemr_client_cert.p12.
176 * If an error occurs, set the $error_msg (which is displayed later below).
178 function create_client_cert() {
179 global $error_msg;
181 if (!$GLOBALS['is_client_ssl_enabled']) {
182 $error_msg .= xl('Error, User Certificate Authentication is not enabled in OpenEMR', 'e');
183 return;
186 if ($_POST["client_cert_user"]) { $user = formData('client_cert_user','P',true); }
187 if ($_POST["client_cert_email"]) { $email = formData('client_cert_email','P',true); }
188 $opensslconf = $GLOBALS['webserver_root'] . "/library/openssl.cnf";
189 $serial = 0;
190 $data = create_user_certificate($user, $email, $serial,
191 $GLOBALS['certificate_authority_crt'],
192 $GLOBALS['certificate_authority_key'],
193 $GLOBALS['client_certificate_valid_in_days']);
194 if ($data === false) {
195 $error_msg .= xl('Error, unable to create client certificate.', 'e');
196 return;
199 $filename = $GLOBALS['temporary_files_dir'] . "/openemr_client_cert.p12";
200 $handle = fopen($filename, 'wt');
201 fwrite($handle, $data);
202 fclose($handle);
204 download_file($filename, "p12");
207 /* Delete the following temporary certificate files, if they exist:
208 * /tmp/CertificateAuthority.key
209 * /tmp/CertificateAuthority.crt
210 * /tmp/Server.key
211 * /tmp/Server.crt
212 * /tmp/admin.p12
213 * /tmp/ssl.zip
215 function delete_certificates() {
216 $tempDir = $GLOBALS['temporary_files_dir'];
217 $files = array("CertificateAuthority.key", "CertificateAuthority.crt",
218 "Server.key", "Server.crt", "admin.p12", "ssl.zip");
220 foreach ($files as $file) {
221 if (file_exists($file)) {
222 unlink($file);
228 * Create and download the following certificates:
229 * - CertificateAuthority.key
230 * - CertificateAuthority.crt
231 * - Server.key
232 * - Server.crt
233 * - admin.p12
234 * The following form inputs are used:
236 function create_and_download_certificates()
238 global $error_msg;
239 $tempDir = $GLOBALS['temporary_files_dir'];
241 $zipName = $tempDir . "/ssl.zip";
242 if (file_exists($zipName)) {
243 unlink($zipName);
246 /* Retrieve the certificate name settings from the form input */
247 if ($_POST["commonName"]) { $commonName = formData('commonName','P',true); }
248 if ($_POST["emailAddress"]) { $emailAddress = formData('emailAddress','P',true); }
249 if ($_POST["countryName"]) { $countryName = formData('countryName','P',true); }
250 if ($_POST["stateOrProvinceName"]) { $stateOrProvinceName = formData('stateOrProvinceName','P',true); }
251 if ($_POST["localityName"]) { $localityName = formData('localityName','P',true); }
252 if ($_POST["organizationName"]) { $organizationName = formData('organizationName','P',true); }
253 if ($_POST["organizationalUnitName"]) { $organizationName = formData('organizationalUnitName','P',true); }
254 if ($_POST["clientCertValidity"]) { $clientCertValidity = formData('clientCertValidity','P',true); }
257 /* Create the Certficate Authority (CA) */
258 $arr = create_csr("OpenEMR CA for " . $commonName, $emailAddress, $countryName, $stateOrProvinceName,$localityName, $organizationName, $organizationalUnitName);
260 if ($arr === false) {
261 $error_msg .= xl('Error, unable to create the Certificate Authority certificate.', 'e');
262 delete_certificates();
263 return;
265 $ca_csr = $arr[0];
266 $ca_key = $arr[1];
267 $ca_crt = create_crt($ca_key, $ca_csr, NULL, $ca_key);
268 if ($ca_crt === false) {
269 $error_msg .= xl('Error, unable to create the Certificate Authority certificate.', 'e');
270 delete_certificates();
271 return;
273 openssl_pkey_export_to_file($ca_key, $tempDir . "/CertificateAuthority.key");
274 openssl_x509_export_to_file($ca_crt, $tempDir . "/CertificateAuthority.crt");
276 /* Create the Server certificate */
277 $arr = create_csr($commonName, $emailAddress, $countryName, $stateOrProvinceName,
278 $localityName, $organizationName, $organizationalUnitName);
279 if ($arr === false) {
280 $error_msg .= xl('Error, unable to create the Server certificate.', 'e');
281 delete_certificates();
282 return;
285 $server_csr = $arr[0];
286 $server_key = $arr[1];
287 $server_crt = create_crt($server_key, $server_csr, $ca_crt, $ca_key);
289 if (server_crt === false) {
290 $error_msg .= xl('Error, unable to create the Server certificate.', 'e');
291 delete_certificates();
292 return;
295 openssl_pkey_export_to_file($server_key, $tempDir . "/Server.key");
296 openssl_x509_export_to_file($server_crt, $tempDir . "/Server.crt");
298 /* Create the client certificate for the 'admin' user */
299 $serial = 0;
300 $res = sqlStatement("select id from users where username='admin'");
301 if ($row = sqlFetchArray($res)) {
302 $serial = $row['id'];
305 $user_cert = create_user_certificate("admin", $emailAddress, $serial,
306 $tempDir . "/CertificateAuthority.crt",
307 $tempDir . "/CertificateAuthority.key",
308 $clientCertValidity);
309 if ($user_cert === false) {
310 $error_msg .= xl('Error, unable to create the admin.p12 certificate.', 'e');
311 delete_certificates();
312 return;
314 $adminFile = $tempDir . "/admin.p12";
315 $handle = fopen($adminFile, 'w');
316 fwrite($handle, $user_cert);
317 fclose($handle);
319 /* Create a zip file containing the CertificateAuthority, Server, and admin files */
320 try {
321 if (! (class_exists('ZipArchive')) ) {
322 $_SESSION["zip_error"]="Error, Class ZipArchive does not exist";
323 return;
326 $zip = new ZipArchive;
327 if(!($zip)) {
328 $_SESSION["zip_error"]="Error, Could not create file archive";
329 return;
332 if ($zip->open($zipName, ZIPARCHIVE::CREATE)) {
333 $files = array("CertificateAuthority.key", "CertificateAuthority.crt",
334 "Server.key", "Server.crt", "admin.p12");
335 foreach ($files as $file) {
336 $zip->addFile($tempDir . "/" . $file, $file);
339 else {
340 $_SESSION["zip_error"]="Error, unable to create zip file with all the certificates";
341 return;
343 $zip->close();
345 if(ini_get('zlib.output_compression')) {
346 ini_set('zlib.output_compression', 'Off');
349 catch (Exception $e) {
350 $_SESSION["zip_error"]="Error, Could not create file archive";
351 return;
354 download_file($zipName, "zip");
359 if (!acl_check('admin', 'users')) {
360 exit();
363 /*if ($_POST["mode"] == "save_ssl_settings") {
364 save_certificate_settings();
367 if ($_POST["mode"] == "create_client_certificate") {
368 create_client_cert();
370 else if ($_POST["mode"] == "download_certificates") {
371 create_and_download_certificates();
376 <html>
377 <head>
378 <script language="Javascript">
381 /* If Enable User Certificate Authentication is set to "Yes", check the following:
382 * - The Client certificate validation period is > 0
383 * - The CertificateAuthority.key path is not empty
384 * - The CertificateAuthority.crt path is not empty
386 /*function save_click() {
387 if (document.ssl_frm.isClientAuthenticationEnabled[0].checked) {
388 if(document.ssl_certificate_frm.clientCertValidity.value > 0) {
389 document.ssl_frm.clientCertValidity_hidden.value = document.ssl_certificate_frm.clientCertValidity.value;
391 else {
392 alert("<?php xl('Client certificate validity should be a valid number.', 'e'); ?>");
393 document.ssl_certificate_frm.clientCertValidity.focus();
394 return false;
396 if (document.ssl_frm.cakey_location.value == "") {
397 alert ("<?php xl('Certificate Authority key file location cannot be empty', 'e'); ?>");
398 document.ssl_frm.cakey_location.focus();
399 return false;
402 if (document.ssl_frm.cacrt_location.value == "") {
403 alert ("<?php xl('Certificate Authority crt file location cannot be empty', 'e'); ?>");
404 document.ssl_frm.cacrt_location.focus();
405 return false;
408 return true;
411 //check whether email id is valid or not
412 function checkEmail(email) {
413 var str=email;
414 var at="@";
415 var dot=".";
416 var lat=str.indexOf(at);
417 var lstr=str.length;
418 var ldot=str.indexOf(dot);
419 if (str.indexOf(at)==-1){
420 return false;
423 if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
424 return false;
427 if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
428 return false;
431 if (str.indexOf(at,(lat+1))!=-1){
432 return false;
435 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
436 return false;
439 if (str.indexOf(dot,(lat+2))==-1){
440 return false;
443 if (str.indexOf(" ")!=-1){
444 return false;
447 return true;
449 function download_click(){
450 if (document.ssl_certificate_frm.commonName.value == "") {
451 alert ("<?php xl('Host Name cannot be empty', 'e'); ?>");
452 document.ssl_certificate_frm.commonName.focus();
453 return false;
456 if (document.ssl_certificate_frm.emailAddress.value) {
457 //call checkEmail function
458 if(checkEmail(document.ssl_certificate_frm.emailAddress.value) == false){
459 alert ("<?php xl('Provide valid Email Address', 'e'); ?>");
460 return false;
464 if (document.ssl_certificate_frm.countryName.value.length > 2) {
465 alert ("<?php xl('Country Name should be represent in two letters. (Example: United States is US)', 'e'); ?>");
466 document.ssl_certificate_frm.countryName.focus();
467 return false;
469 if (document.ssl_certificate_frm.clientCertValidity.value < 1) {
470 alert ("<?php xl('Client certificate validity should be a valid number.', 'e'); ?>");
471 document.ssl_certificate_frm.clientCertValidity.focus();
472 return false;
475 function create_client_certificate_click(){
477 /*if(document.ssl_frm.isClientAuthenticationEnabled[1].checked == true)
479 alert ("<?php xl('User Certificate Authentication is disabled', 'e'); ?>");
480 return false;
483 if (document.client_cert_frm.client_cert_user.value == "") {
484 alert ("<?php xl('User name or Host name cannot be empty', 'e'); ?>");
485 document.ssl_certificate_frm.commonName.focus();
486 return false;
488 if (document.client_cert_frm.client_cert_email.value) {
489 //call checkEmail function
490 if(checkEmail(document.client_cert_frm.client_cert_email.value) == false){
491 alert ("<?php xl('Provide valid Email Address', 'e'); ?>");
492 return false;
497 function isNumberKey(evt) {
498 var charCode = (evt.which) ? evt.which : evt.keyCode
499 if (charCode > 31 && (charCode < 48 || charCode > 57))
500 return false;
501 else
502 return true;
505 </script>
507 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
508 <style type="text/css">
509 div.borderbox {
510 margin: 5px 5px;
511 padding: 5px 5px;
512 border: solid 1px;
513 width: 60%;
515 </style>
517 </head>
518 <body class="body_top">
519 <span class='title'><b><?php xl('SSL Certificate Administration', 'e'); ?></b></span>
520 </br> </br>
521 <?php if($_SESSION["zip_error"]) { ?>
522 <div> <table align="center" >
523 <tr valign="top"> <td rowspan="3"> <?php echo "<font class='redtext'>" . xl($_SESSION["zip_error"]) ?> </td> </tr>
524 </table> <?php
525 unset($_SESSION["zip_error"]); ?></div>
526 <?php } else { ?>
527 <span class='text'>
528 <?php
529 if ($error_msg != "") {
530 echo "<font class='redtext'>" . $error_msg . "</font><br><br>";
533 <?php xl('To setup https access with client certificate authentication, do the following', 'e'); ?>
534 <ul>
535 <li><?php xl('Create the SSL Certificate Authority and Server certificates.', 'e'); ?>
536 <li><?php xl('Configure Apache to use HTTPS.', 'e'); ?>
537 <li><?php xl('Configure Apache and OpenEMR to use Client side SSL certificates.', 'e'); ?>
538 <li><?php xl('Import certificate to the browser.', 'e'); ?>
539 <li><?php xl('Create a Client side SSL certificate for each user or client machine.', 'e'); ?>
540 </ul>
541 <br>
542 <?php
543 if ($GLOBALS['certificate_authority_crt'] != "" && $GLOBALS['is_client_ssl_enabled']) {
544 xl('OpenEMR already has a Certificate Authority configured.', 'e');
547 <form method='post' name=ssl_certificate_frm action='ssl_certificates_admin.php'>
548 <input type='hidden' name='mode' value='download_certificates'>
549 <div class='borderbox'>
550 <b><?php xl('Create the SSL Certificate Authority and Server certificates.', 'e'); ?></b><br>
551 <br>
552 1. <?php xl('Fill in the values below', 'e'); ?><br>
553 2. <?php xl('Click Download Certificate to download the certificates in the file ssl.zip', 'e'); ?> <br>
554 3. <?php xl('Extract the zip file', 'e'); echo ": ssl.zip "; ?><br></br>
555 <?php xl('The zip file will contain the following items', 'e'); ?> <br>
556 <ul>
557 <li>Server.crt : <?php xl('The Apache SSL server certificate and public key', 'e'); ?>
558 <li>Server.key : <?php xl('The corresponding private key', 'e'); ?>
559 <li>CertificateAuthority.crt : <?php xl('The Certificate Authority certificate', 'e'); ?>
560 <li>CertificateAuthority.key : <?php xl('The corresponding private key', 'e'); ?>
561 <li>admin.p12 : <?php xl('A client certificate for the admin user', 'e'); ?>
562 </ul>
563 <table border=0>
564 <tr class='text'>
565 <td><?php xl('Host Name', 'e'); ?> *:</td>
566 <td><input name='commonName' type='text' value=''></td>
567 <td><?php xl('Example', 'e') ; echo ': hostname.domain.com'; ?></td>
568 </tr>
569 <tr class='text'>
570 <td><?php xl('Email Address', 'e'); ?>:</td>
571 <td><input name='emailAddress' type='text' value=''></td>
572 <td><?php xl('Example', 'e') ; echo ': web_admin@domain.com'; ?></td>
573 </tr>
574 <tr class='text'>
575 <td><?php xl('Organization Name', 'e'); ?>:</td>
576 <td><input name='organizationName' type='text' value=''></td>
577 <td><?php xl('Example', 'e'); echo ': My Company Ltd'; ?></td>
578 </tr>
579 <tr class='text'>
580 <td><?php xl('Organizational Unit Name', 'e'); ?>:</td>
581 <td><input name='organizationalUnitName' type='text' value=''></td>
582 <td><?php xl('Example', 'e'); echo ': OpenEMR'; ?></td>
583 </tr>
584 <tr class='text'>
585 <td><?php xl('Locality', 'e'); ?>:</td>
586 <td><input name='localityName' type='text' value=''></td>
587 <td><?php xl('Example', 'e') ; echo ': City'; ?></td>
588 </tr>
589 <tr class='text'>
590 <td><?php xl('State Or Province', 'e'); ?>:</td>
591 <td><input name='stateOrProvinceName' type='text' value=''></td>
592 <td><?php xl('Example', 'e') ; echo ': California'; ?></td>
593 </tr>
594 <tr class='text'>
595 <td><?php xl('Country', 'e'); ?>:</td>
596 <td><input name='countryName' type='text' value='' maxlength='2'></td>
597 <td><?php xl('Example', 'e'); echo ': US'; echo ' ('; xl('Should be two letters', 'e'); echo ')'; ?></td>
598 </tr>
599 <tr class='text'>
600 <td><?php xl('Client certificate validation period', 'e'); ?>:</td>
601 <td><input name='clientCertValidity' type='text' onkeypress='return isNumberKey(event)' value='365'></td>
602 <td><?php xl('days', 'e'); ?></td>
603 </tr>
604 <tr>
605 <td colspan=3 align='center'>
606 <input name='sslcrt' type='submit' onclick='return download_click();' value='<?php xl('Download Certificates', 'e'); ?>'>
607 </td>
608 </tr>
609 </table>
610 </div>
611 </form>
612 <br>
614 <div class="borderbox">
615 <b><?php xl('Configure Apache to use HTTPS.', 'e'); ?></b><br>
616 <br>
617 <?php xl('Add new certificates to the Apache configuration file', 'e'); ?>:<br>
618 <br>
619 SSLEngine on<br>
620 SSLCertificateFile /path/to/Server.crt<br>
621 SSLCertificateKeyFile /path/to/Server.key<br>
622 SSLCACertificateFile /path/to/CertificateAuthority.crt<br>
623 <br>
624 <?php xl('Note','e'); ?>:
625 <ul>
626 <li><?php xl('To Enable only HTTPS, perform the above changes and restart Apache server. If you want to configure client side certificates also, please configure them in the next section.', 'e'); ?></br>
627 <li> <?php xl('To Disable HTTPS, comment the above lines in Apache configuration file and restart Apache server.', 'e'); ?>
628 <ul/>
629 </div>
631 <br>
632 <div class="borderbox">
633 <form name='ssl_frm' method='post'>
634 <b><?php xl('Configure Apache to use Client side SSL certificates', 'e'); ?> </b>
635 <br></br>
636 <?php xl('Add following lines to the Apache configuration file', 'e'); ?>:<br>
637 </br>
638 SSLVerifyClient require<br>
639 SSLVerifyDepth 2<br>
640 SSLOptions +StdEnvVars<br>
641 <!--/br> <b><?php xl('Configure Openemr to use Client side SSL certificates', 'e'); ?> </b></br>
642 <input type='hidden' name='clientCertValidity_hidden' value=''>
643 <input type='hidden' name='mode' value='save_ssl_settings'></br>
644 <table cellpadding=0 cellspacing=0>
645 <tr class='text'>
646 <td><?php xl('Enable User Certificate Authentication', 'e'); ?>:</td>
647 <td>
648 <input name='isClientAuthenticationEnabled' type='radio' value='Yes'
649 <?php if ($GLOBALS['is_client_ssl_enabled']) echo "checked"; ?> > <?php xl('Yes', 'e'); ?>
650 <input name='isClientAuthenticationEnabled' type='radio' value='No' <?php if (!$GLOBALS['is_client_ssl_enabled']) echo "checked"; ?> > <?php xl('No', 'e'); ?>
651 </td>
652 </tr>
653 <tr><td>&nbsp;</td></tr>
654 <tr class='text'>
655 <td>CertificateAuthority.key <?php xl('file location', 'e'); ?>: </td>
656 <td>
657 <input type='hidden' name='hiden_cakey' />
658 <input name='cakey_location' type='text' size=20 value='<?php echo $GLOBALS['certificate_authority_key'] ?>' /> (<?php xl('Provide absolute path', 'e'); ?>)
659 </td>
660 </tr>
661 <tr class='text'>
662 <td>CertificateAuthority.crt <?php xl('file location', 'e'); ?>: </td>
663 <td>
664 <input type='hidden' name='hiden_cacrt' />
665 <input name='cacrt_location' type=text size=20 value='<?php echo $GLOBALS['certificate_authority_crt'] ?>'/> (<?php xl('Provide absolute path', 'e'); ?>)
666 </td>
667 </tr>
668 </table>
669 </br>
670 <input type='submit' value='<?php xl('Save Certificate Settings', 'e'); ?>' onclick='return save_click();'-->
671 </br> <b><?php xl('Configure Openemr to use Client side SSL certificates', 'e'); ?> </b></br>
672 <input type='hidden' name='clientCertValidity_hidden' value=''>
673 </br>
675 <?php xl('Update the following variables in file', 'e'); ?>: globals.php</br></br>
676 <?php xl('To enable Client side ssl certificates', 'e'); ?></br>
677 <?php xl('Set', 'e'); ?> 'is_client_ssl_enabled' <?php xl('to', 'e'); ?> 'true' </br></br>
678 <?php xl('Provide absolute path of file', 'e'); ?> CertificateAuthority.key</br>
679 <?php xl('Set', 'e'); ?> 'certificate_authority_key' <?php xl('to absolute path of file', 'e'); ?> 'CertificateAuthority.key'</br></br>
680 <?php xl('Provide absolute path of file', 'e'); ?> CertificateAuthority.crt</br>
681 <?php xl('Set', 'e'); ?> 'certificate_authority_crt' <?php xl('to absolute path of file', 'e'); ?> 'CertificateAuthority.crt'</br>
682 <br>
683 </br><?php xl('Note','e'); ?>:
684 <ul>
685 <li><?php xl('To Enable Client side SSL certificates authentication, HTTPS should be enabled.', 'e'); ?>
686 <li><?php xl('After performing above configurations, import the admin client certificate to the browser and restart Apache server (empty password).', 'e'); ?>
687 <li><?php xl('To Disable client side SSL certificates, comment above lines in Apache configuration file and set', 'e'); ?> 'false' <?php xl('for variable', 'e'); ?> 'is_client_ssl_enabled' (globals.php) <?php xl('and restart Apache server.', 'e'); ?>
688 </form>
689 </div>
690 <br>
691 <div class="borderbox">
692 <b><?php xl('Create Client side SSL certificates', 'e'); ?></b><br>
693 <br>
694 <?php xl('Create a client side SSL certificate for either a user or a client hostname.', 'e'); ?>
695 <br>
696 <?php
697 if (!$GLOBALS['is_client_ssl_enabled'] ||
698 $GLOBALS['certificate_authority_crt'] == "") {
699 echo "<font class='redtext'>" . xl('OpenEMR must be configured to use certificates before it can create client certificates.', 'e') . "</font><br>";
702 <form name='client_cert_frm' method='post' action='ssl_certificates_admin.php'>
703 <input type='hidden' name='mode' value='create_client_certificate'>
704 <table>
705 <tr class='text'>
706 <td><?php xl('User or Host name', 'e'); ?>*:</td>
707 <td><input type='text' name='client_cert_user' size=20 />
708 </tr>
709 <tr class='text'>
710 <td><?php xl('Email', 'e'); ?>:</td>
711 <td><input type='text' name='client_cert_email' size=20 />
712 </tr>
713 </table>
714 </br> <input type='submit' onclick='return create_client_certificate_click();' value='<?php xl('Create Client Certificate', 'e'); ?>'>
715 </form>
716 </div>
717 <br>
718 <br>&nbsp;
719 <br>&nbsp;
720 </span>
721 <?php } ?>
722 </body>
723 </html>