--- admin/plib/modules/panel-migrator/backend/lib/python/parallels/plesk/source/confixx/extras/pmm/Agent.pm.orig +++ admin/plib/modules/panel-migrator/backend/lib/python/parallels/plesk/source/confixx/extras/pmm/Agent.pm @@ -10,6 +10,7 @@ use warnings; use XmlNode; use CommonXmlNodes; +use PerlMD5; use AgentConfig; use Dumper; @@ -1490,6 +1491,7 @@ sub _makeSiteNode { # $mailUser could be undef for wildcard subdomains as they do not have e-mail defined($mailUsers) ? _getMailSystem($clientName, $siteName) : undef, defined($mailUsers) ? _makeSiteMaillistsNode($clientInfo, $siteName) : undef, + _makeSslNode($clientInfo->{'kunde'}), _makeSiteHostingNode($clientInfo, $siteInfo, $systemDomainName) ] ); @@ -1633,9 +1635,30 @@ sub _makeSiteHostingNode { ] ); + if ($domainInfo_ptr->{'cssl'} != CSSL_NONE) { + my @csslRecords = Dumper::getClientSSLRecords($customerInfo_ptr->{'kunde'}); + if (@csslRecords) { + my $csslInfo_ptr = $csslRecords[0]; + if ($csslInfo_ptr->{'crt'} && $csslInfo_ptr->{'privatekey'}) { + $pHostingNode->setAttribute('certificate', _getCertificateRef($csslInfo_ptr->{'privatekey'})); + } + } + } + return $pHostingNode; } +sub _getCertificateRef { + my ($privateKey) = @_; + # XML normalization: remove starting/ending newlines, remove symbols. + # That is necessary so we get the same result after we write private key to XML, then read it from the XML. + $privateKey =~ s/\r|^\s+|\s+$//g; + + my $md5 = PerlMD5->new(); + $md5->add($privateKey); + return $md5->hexdigest(); +} + # # == HTTPD specials == # HTTPD specials are migrated into vhost.conf. Plesk doesn't provide the functionality that @@ -1732,6 +1755,9 @@ sub _makeSslNode { return undef; } + my $privateKey = $csslInfo_ptr->{'privatekey'}; + $privateKey =~ s/\r|^\s+|\s+$//g; + my $certificatesNode = XmlNode->new('certificates', 'children' => [ XmlNode->new('certificate', @@ -1740,7 +1766,7 @@ sub _makeSslNode { }, 'children' => [ XmlNode->new('certificate-data', 'content' => $csslInfo_ptr->{'crt'}), - XmlNode->new('private-key', 'content' => $csslInfo_ptr->{'privatekey'}) + XmlNode->new('private-key', 'content' => $privateKey) ] ) ]