diff --git a/server/plugins-available/apps_vhost_plugin.inc.php b/server/plugins-available/apps_vhost_plugin.inc.php
index 58f39ea03af6987c3a94fbf1c313fcc81dda24a2..a8797c62afcf0e8cd2c59aefd1fdb58e40f070c6 100644
--- a/server/plugins-available/apps_vhost_plugin.inc.php
+++ b/server/plugins-available/apps_vhost_plugin.inc.php
@@ -107,6 +107,18 @@ class apps_vhost_plugin {
 			}
 			$tpl->setVar('vhost_port_listen', $vhost_port_listen);
 
+			/* Check if SSL should be enabled: */
+			if(is_file('/usr/local/ispconfig/interface/ssl/ispserver.crt') && is_file('/usr/local/ispconfig/interface/ssl/ispserver.key')) {
+				$tpl->setVar('ssl_comment','');
+			} else {
+				$tpl->setVar('ssl_comment','#');
+			}
+			if(is_file('/usr/local/ispconfig/interface/ssl/ispserver.crt') && is_file('/usr/local/ispconfig/interface/ssl/ispserver.key') && is_file('/usr/local/ispconfig/interface/ssl/ispserver.bundle')) {
+				$tpl->setVar('ssl_bundle_comment','');
+			} else {
+				$tpl->setVar('ssl_bundle_comment','#');
+			}
+
 			$mail_config = $app->getconf->get_server_config($conf['server_id'], 'mail');
 			if($mail_config['content_filter'] == 'rspamd'){
 				$use_rspamd = true;
@@ -127,17 +139,6 @@ class apps_vhost_plugin {
 			$content = str_replace('{apps_vhost_basedir}', $web_config['website_basedir'], $content);
 			$content = str_replace('{vhost_port_listen}', $vhost_port_listen, $content);
 			/* end of backwards compatibility section */
-			/* Check if SSL should be enabled: */
-			if(is_file($install_dir.'/interface/ssl/ispserver.crt') && is_file($install_dir.'/interface/ssl/ispserver.key')) {
-				$tpl->setVar('ssl_comment','');
-			} else {
-				$tpl->setVar('ssl_comment','#');
-			}
-			if(is_file($install_dir.'/interface/ssl/ispserver.crt') && is_file($install_dir.'/interface/ssl/ispserver.key') && is_file($install_dir.'/interface/ssl/ispserver.bundle')) {
-				$tpl->setVar('ssl_bundle_comment','');
-			} else {
-				$tpl->setVar('ssl_bundle_comment','#');
-			}
 
 			$app->system->file_put_contents("$vhost_conf_dir/apps.vhost", $content);