function dbactionUpdate($subaction)
 {
     $name = sslcert::getSslCertnameFromIP($this->main->nname);
     $path = "__path_ssl_root";
     $contentscer = $this->main->text_crt_content;
     $contentskey = $this->main->text_key_content;
     $contentsca = trim($this->main->text_ca_content);
     if (!$contentscer || !$contentskey) {
         throw new lxException("certificate_key_file_empty", '');
     }
     sslcert::checkAndThrow($contentscer, $contentskey, $name);
     lfile_put_contents("{$path}/{$name}.crt", $contentscer);
     lfile_put_contents("{$path}/{$name}.key", $contentskey);
     $contentpem = "{$contentscer}\n{$contentskey}";
     lfile_put_contents("{$path}/{$name}.pem", $contentpem);
     if ($contentsca) {
         lfile_put_contents("{$path}/{$name}.ca", $contentsca);
     } else {
         lxfile_cp("htmllib/filecore/program.ca", "{$path}/{$name}.ca");
     }
     createRestartFile($this->main->__var_webdriver);
 }
Example #2
0
 static function copyCertificate($devname, $machinename)
 {
     $name = $devname . "___" . $machinename;
     $name = sslcert::getSslCertnameFromIP($name);
     if (!lxfile_exists("__path_ssl_root")) {
         lxfile_mkdir("__path_ssl_root");
     }
     if (!lxfile_exists("__path_ssl_root/{$name}.crt")) {
         lxfile_cp("__path_program_root/file/default.crt", "__path_ssl_root/{$name}.crt");
     }
     if (!lxfile_exists("__path_ssl_root/{$name}.key")) {
         lxfile_cp("__path_program_root/file/default.key", "__path_ssl_root/{$name}.key");
     }
     if (!lxfile_exists("__path_ssl_root/{$name}.ca")) {
         lxfile_cp("__path_program_root/file/default.ca", "__path_ssl_root/{$name}.ca");
     }
 }
Example #3
0
 function sslsysnc($ipad)
 {
     global $gbl, $sgbl, $login, $ghtml;
     $ssl_root = $sgbl->__path_ssl_root;
     $ssl_cert = null;
     foreach ((array) $this->main->__var_ipssllist as $ip) {
         // Get the first certificate;
         if (!$ipad) {
             $ssl_cert = sslcert::getSslCertnameFromIP($ip['nname']);
             break;
         }
         if ($ip['ipaddr'] === $ipad) {
             $ssl_cert = sslcert::getSslCertnameFromIP($ip['nname']);
             break;
         }
     }
     if (!$ssl_cert) {
         return;
     }
     $string = null;
     $certificatef = "{$ssl_root}/{$ssl_cert}.crt";
     $keyfile = "{$ssl_root}/{$ssl_cert}.key";
     $cafile = "{$ssl_root}/{$ssl_cert}.ca";
     sslcert::checkAndThrow(lfile_get_contents($certificatef), lfile_get_contents($keyfile), $ssl_cert);
     $string .= "\tSSLEngine On \n";
     $string .= "\tSSLCertificateFile {$certificatef}\n";
     $string .= "\tSSLCertificateKeyFile {$keyfile}\n";
     $string .= "\tSSLCACertificatefile {$cafile}\n\n";
     return $string;
 }
Example #4
0
 static function add($parent, $class, $param)
 {
     if (isset($param['upload'])) {
         if ($param['upload'] === 'uploadfile') {
             $key_file = $_FILES['ssl_key_file_f']['tmp_name'];
             $crt_file = $_FILES['ssl_crt_file_f']['tmp_name'];
             $ca_file = $_FILES['ssl_ca_file_f']['tmp_name'];
             if (!$key_file || !$crt_file) {
                 throw new lxException("key_crt_files_needed");
             }
             $param['text_key_content'] = file_get_contents($key_file);
             $param['text_crt_content'] = file_get_contents($crt_file);
             if ($ca_file && lxfile_exists($ca_file)) {
                 $param['text_ca_content'] = lfile_get_contents($ca_file);
             }
         }
         sslcert::checkAndThrow($param['text_crt_content'], $param['text_key_content']);
         $param['upload_status'] = 'on';
     } else {
         $param['upload_status'] = 'off';
     }
     $param['certname'] = $param['nname'];
     return $param;
 }
Example #5
0
 function getSslCert($ip)
 {
     global $gbl, $sgbl, $login, $ghtml;
     $string = null;
     $ssl_cert = null;
     $ssl_cert = sslcert::getSslCertnameFromIP($ip['nname']);
     $certificatef = "{$sgbl->__path_ssl_root}/{$ssl_cert}.crt";
     $keyfile = "{$sgbl->__path_ssl_root}/{$ssl_cert}.key";
     $pemfile = "{$sgbl->__path_ssl_root}/{$ssl_cert}.pem";
     $cafile = "{$sgbl->__path_ssl_root}/{$ssl_cert}.ca";
     sslcert::checkAndThrow(lfile_get_contents($certificatef), lfile_get_contents($keyfile), $ssl_cert);
     if (!lxfile_exists($pemfile)) {
         $c = lfile_get_contents($certificatef);
         $k = lfile_get_contents($keyfile);
         lfile_put_contents($pemfile, "{$c}\n{$k}");
     }
     $string .= "\tssl.engine = \"enable\"\n";
     $string .= "\tssl.pemfile = \"{$pemfile}\"\n";
     $string .= "\tssl.ca-file = \"{$cafile}\"\n\n";
     return $string;
 }