Пример #1
0
 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);
 }
Пример #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");
     }
 }
Пример #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;
 }
Пример #4
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;
 }