Need help defining different certificate to be use with a domain pointer

goftari

Verified User
Joined
Jun 18, 2022
Messages
10
Hello all,
I have defined a domain pointer for the main domain and need to change custom httpd configurations on DirectAdmin for the new pointer to use a new certificate.
The new domain pointer may be identified by ServerName and ServerAlias directives. But I only found DOMAIN and HOSTNAME tokens available to write an if statement with. could you please help me find a way to carry out this change.
 
Thanks @Zhenyapan for your reply.
That was exactly what I have tried but as I mentioned, didn't find any token to use for matching ServerName or ServerAlias directive in the attended block.
I tried updating CERT and KEY by using below format and matching my domain pointer name using DOMAIN and HOSTNAME tokens
|*if DOMAIN="domain.com"|
|?CERT=/usr/local/directadmin/data/users/user/domains/domain.com.cert.combined|
|?KEY=/usr/local/directadmin/data/users/user/domains/domain.com.key|
|*endif|
 
Last edited:
You might try and use PHP in templates to parse and process the token |SERVER_ALIASES| and change the certificate path:

Using the following code:

PHP:
|$/usr/local/bin/php
<?
$data = "|SERVER_ALIASES|";
$cert = "|CERT|";
$key = "|KEY|";
$data = explode(" ", trim($data));
foreach ($data as $alias)
{
   $n_cert = dirname($cert).'/'.$alias.'.cert.combined;';
   $n_key = dirname($key).'/'.$alias.'.key';
   echo "         SSLCertificateFile $n_cert;\n";
   echo "         SSLCertificateKeyFile $n_key;\n";
}
?>
DONE|

Please note, this is just an example. IT IS NOT READY FOR PRODUCTION USE! You will need to expand the example and build complete VirtualHost for every alias.
 
You might try and use PHP in templates to parse and process the token |SERVER_ALIASES| and change the certificate path:

Using the following code:

PHP:
|$/usr/local/bin/php
<?
$data = "|SERVER_ALIASES|";
$cert = "|CERT|";
$key = "|KEY|";
$data = explode(" ", trim($data));
foreach ($data as $alias)
{
   $n_cert = dirname($cert).'/'.$alias.'.cert.combined;';
   $n_key = dirname($key).'/'.$alias.'.key';
   echo "         SSLCertificateFile $n_cert;\n";
   echo "         SSLCertificateKeyFile $n_key;\n";
}
?>
DONE|

Please note, this is just an example. IT IS NOT READY FOR PRODUCTION USE! You will need to expand the example and build complete VirtualHost for every alias.
Thanks Alex @zEitEr
And I will need to enable tokenize_script_output=1 in directadmin.conf to use this feature. Am I right?
 
Back
Top