Skip to content

Commit

Permalink
Fix Connectivity to Azure MariaDB over TLS with New Combined CA
Browse files Browse the repository at this point in the history
Azure is rotating CA certificates and now requires server operators to
use a "combined" CA file that has the root certificates for both the
BaltimoreCyberTrustRoot and DigiCertGlobalRootG2 CAs. It appears that
Azure is migrating from BaltimoreCyberTrustRoot to DigiCertGlobalRootG2.

More information is here:
https://learn.microsoft.com/en-us/azure/mariadb/concepts-certificate-rotation
  • Loading branch information
Guy Elsmore-Paddock committed Apr 27, 2023
1 parent 9f90487 commit 8662be5
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 21 deletions.
5 changes: 5 additions & 0 deletions docker/backend-nextcloud-apache/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ RUN /setup_newrelic.sh && rm /setup_newrelic.sh
COPY nextcloud-common/entrypoint.sh /
COPY nextcloud-common/config/* /usr/src/nextcloud/config/

# Create combined CA file, per:
# https://learn.microsoft.com/en-us/azure/mariadb/concepts-certificate-rotation
COPY nextcloud-common/ssl/azure_ca/ /tmp/azure_ca
RUN cat /tmp/azure_ca/*.pem >/usr/src/nextcloud/config/azure_ca.pem

# We supply all custom apps via Docker image; app store is disabled
COPY nextcloud-common/custom_apps/. /usr/src/nextcloud/custom_apps/

Expand Down
5 changes: 5 additions & 0 deletions docker/backend-nextcloud-fpm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ RUN /setup_newrelic.sh && rm /setup_newrelic.sh
COPY nextcloud-common/entrypoint.sh /
COPY nextcloud-common/config/* /usr/src/nextcloud/config/

# Create combined CA file, per:
# https://learn.microsoft.com/en-us/azure/mariadb/concepts-certificate-rotation
COPY nextcloud-common/ssl/azure_ca/ /tmp/azure_ca
RUN cat /tmp/azure_ca/*.pem >/usr/src/nextcloud/config/azure_ca.pem

# We supply all custom apps via Docker image; app store is disabled
COPY nextcloud-common/custom_apps/. /usr/src/nextcloud/custom_apps/

Expand Down
36 changes: 15 additions & 21 deletions docker/nextcloud-common/config/mysql-ssl.config.php
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
<?php
$all_ssl_ca_locations = [
# Location of Azure Trusted CA on Alpine Linux
'/etc/ssl/certs/ca-cert-Baltimore_CyberTrust_Root.pem',
/**
* The name of the combined CA file that gets created during the Docker build.
*
* The CA file contains certificates for both BaltimoreCyberTrustRoot and
* DigiCertGlobalRootG2, per the instructions from this article:
* https://learn.microsoft.com/en-us/azure/mariadb/concepts-certificate-rotation
*/
const AZURE_CA_PEM_FILE = 'azure_ca.pem';

# Location of Azure Trusted CA on Ubuntu Linux
'/etc/ssl/certs/Baltimore_CyberTrust_Root.pem',
];
$config_folder = dirname(__FILE__);

foreach ($all_ssl_ca_locations as $location) {
if (is_file($location)) {
$ssl_ca_location = $location;
break;
}
}

if (!empty($ssl_ca_location)) {
# Support connecting to Azure MySQL over SSL
$CONFIG = array(
'dbdriveroptions' => array(
PDO::MYSQL_ATTR_SSL_CA => $ssl_ca_location,
),
);
}
# Support connecting to Azure MySQL over SSL
$CONFIG = array(
'dbdriveroptions' => array(
PDO::MYSQL_ATTR_SSL_CA => sprintf('%s/%s', $config_folder, AZURE_CA_PEM_FILE),
),
);
1 change: 1 addition & 0 deletions docker/nextcloud-common/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ deploy_nextcloud_release() {
echo "'config' directory is writable."
echo "Sync-ing configuration snippets:"
cp -v /usr/src/nextcloud/config/*.config.php /var/www/html/config/
cp -v /usr/src/nextcloud/config/*.pem /var/www/html/config/
echo ""
else
echo "'config' directory is not writable."
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
-----BEGIN CERTIFICATE-----
MIIDdzCCAl+gAwIBAgIEAgAAuTANBgkqhkiG9w0BAQUFADBaMQswCQYDVQQGEwJJ
RTESMBAGA1UEChMJQmFsdGltb3JlMRMwEQYDVQQLEwpDeWJlclRydXN0MSIwIAYD
VQQDExlCYWx0aW1vcmUgQ3liZXJ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deletions docker/nextcloud-common/ssl/azure_ca/DigiCertGlobalRootG2.crt.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
-----BEGIN CERTIFICATE-----
MIIDjjCCAnagAwIBAgIQAzrx5qcRqaC7KGSxHQn65TANBgkqhkiG9w0BAQsFADBh
MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBH
MjAeFw0xMzA4MDExMjAwMDBaFw0zODAxMTUxMjAwMDBaMGExCzAJBgNVBAYTAlVT
MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j
b20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IEcyMIIBIjANBgkqhkiG
9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuzfNNNx7a8myaJCtSnX/RrohCgiN9RlUyfuI
2/Ou8jqJkTx65qsGGmvPrC3oXgkkRLpimn7Wo6h+4FR1IAWsULecYxpsMNzaHxmx
1x7e/dfgy5SDN67sH0NO3Xss0r0upS/kqbitOtSZpLYl6ZtrAGCSYP9PIUkY92eQ
q2EGnI/yuum06ZIya7XzV+hdG82MHauVBJVJ8zUtluNJbd134/tJS7SsVQepj5Wz
tCO7TG1F8PapspUwtP1MVYwnSlcUfIKdzXOS0xZKBgyMUNGPHgm+F6HmIcr9g+UQ
vIOlCsRnKPZzFBQ9RnbDhxSJITRNrw9FDKZJobq7nMWxM4MphQIDAQABo0IwQDAP
BgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAdBgNVHQ4EFgQUTiJUIBiV
5uNu5g/6+rkS7QYXjzkwDQYJKoZIhvcNAQELBQADggEBAGBnKJRvDkhj6zHd6mcY
1Yl9PMWLSn/pvtsrF9+wX3N3KjITOYFnQoQj8kVnNeyIv/iPsGEMNKSuIEyExtv4
NeF22d+mQrvHRAiGfzZ0JFrabA0UWTW98kndth/Jsw1HKj2ZL7tcu7XUIOGZX1NG
Fdtom/DzMNU+MeKNhJ7jitralj41E6Vf8PlwUHBHQRFXGU7Aj64GxJUTFy8bJZ91
8rGOmaFvE7FBcf6IKshPECBV1/MUReXgRPTqh5Uykw7+U0b6LJ3/iyK5S9kJRaTe
pLiaWN0bfVKfjllDiIGknibVb63dDcY3fe0Dkhvld1927jyNxF1WW6LZZm6zNTfl
MrY=
-----END CERTIFICATE-----
5 changes: 5 additions & 0 deletions docker/nextcloud-cron/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ RUN rm -f /usr/src/nextcloud/config/redis.config.php
COPY nextcloud-cron/entrypoint.sh /
COPY nextcloud-common/config/* /usr/src/nextcloud/config/

# Create combined CA file, per:
# https://learn.microsoft.com/en-us/azure/mariadb/concepts-certificate-rotation
COPY nextcloud-common/ssl/azure_ca/ /tmp/azure_ca
RUN cat /tmp/azure_ca/*.pem >/usr/src/nextcloud/config/azure_ca.pem

COPY nextcloud-cron/cleanup_uploads.sh /

# Ensure custom apps are available during cron runs.
Expand Down

0 comments on commit 8662be5

Please sign in to comment.