Custom Object Gateway SSL/TLS Certificate: Difference between revisions

From OSNEXUS Online Documentation Site
Jump to navigation Jump to search
m Joshua moved page Custom Object Gateway SSl/TLS Certificate to Custom Object Gateway SSL/TLS Certificate: Correct the title typo (SSl -> SSL). The old title stays as a redirect.
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
When configuring QuantaStor scale-out clusters with an object storage zone it is important to setup a SSL/TLS certification to associate with the S3 gateway (CephRGW) so that clients connecting are able to validate the certificate against either an internal or public certificate authority (CA).  This article goes of the procedure for making a SSL certificate for that purpose using OpenSSL along with a series of 'Alt Names' or 'Subject Alt Names' which identifies all the FQDNs for all the ports on all the QuantaStor systems that make up the cluster and any floating cluster wide FQDNs that my be used to access the S3 gateways.
This page shows how to create a private key and certificate signing request (CSR) for the object storage (S3) service with OpenSSL, have your certificate authority (CA) sign it, and turn the result into the PEM file QuantaStor uses. To apply the finished file to the systems, see [[Certificate Template Manager]].


== S3 Certificate CSR generation and signing using Windows AD/Certificate Authority ==
Create the certificate before you deploy the object gateways if you can, so you can give it to the gateways when you create them.


=== Prepare Certs Directory ===
* [[#Choosing the names|Choosing the names]]
Start by creating a empty directory to store the certificates to be generated.
* [[#Creating the key and CSR|Creating the key and CSR]]
* [[#Having the CSR signed|Having the CSR signed]]
* [[#Converting the CA's files to PEM|Converting the CA's files to PEM]]
* [[#Building the PEM file|Building the PEM file]]
* [[#Applying the certificate|Applying the certificate]]
* [[#Trusting the CA on clients|Trusting the CA on clients]]
* [[#Testing from a client|Testing from a client]]


<pre>
== Choosing the names ==
mkdir s3_adtest_osnexus_net_crt
 
cd s3_adtest_osnexus_net_crt
Clients check that the name they connect to appears in the certificate's Subject Alternative Name (SAN) list. Include:
 
* the S3 endpoint name clients use, for example {{Code|1=s3.example.com}},
* a wildcard for that name, for example {{Code|1=*.s3.example.com}}, if clients put the bucket name in the host name (virtual-hosted style),
* each system's own name, if clients connect to systems directly,
* any IP address clients connect to.
 
QuantaStor refuses a certificate that has no SAN.
 
== Creating the key and CSR ==
 
Work in an empty directory:
 
<pre style="font-size: smaller">
mkdir s3_cert
cd s3_cert
</pre>
</pre>


=== Create OpenSSL Configuration File ===
Create a file named {{Code|1=openssl.cnf}}. Change the values under {{Code|1=[ req_distinguished_name ]}} to your organisation's, and list your names under {{Code|1=[ alt_names ]}}:
 
Next create a file named openssl.cnf that contains the proper values for your site, and the '''Subject Alt Names''' you wish to have match FQDN to IP mappings in your DNS.  Here's an example openssl configuration file (save as openssl.cnf), you  can start with this one and edit the values to match your organization.  Be sure to change all the values under '''[ alt_names ]''' and under '''[ req_distinguished_name ]''' to match the settings for your organization :


<pre>
<pre style="font-size: smaller">
[ req ]
[ req ]
default_bits      = 2048
default_bits      = 2048
Line 22: Line 41:
distinguished_name = req_distinguished_name
distinguished_name = req_distinguished_name
req_extensions    = req_ext
req_extensions    = req_ext
x509_extensions    = v3_req


[ req_distinguished_name ]
[ req_distinguished_name ]
Line 28: Line 46:
ST = Washington
ST = Washington
L  = Bellevue
L  = Bellevue
O  = OSNEXUS Development
O  = Example Organization
OU = s3 services
OU = Storage
CN = s3.example.com


[ req_ext ]
[ req_ext ]
subjectAltName = @alt_names
[ v3_req ]
subjectAltName = @alt_names
subjectAltName = @alt_names


[ alt_names ]
[ alt_names ]
DNS.1   = s3.adtest.osnexus.net
DNS.1 = s3.example.com
DNS.2   = cg-631f-201.adtest.osnexus.net
DNS.2 = *.s3.example.com
DNS.3   = cg-631f-202.adtest.osnexus.net
DNS.3 = qs-node1.example.com
DNS.4   = cg-631f-203.adtest.osnexus.net
DNS.4 = qs-node2.example.com
DNS.5   = vif205.adtest.osnexus.net
DNS.5 = qs-node3.example.com
DNS.6  = vif206.adtest.osnexus.net
IP.1 = 192.0.2.11
DNS.7  = vif207.adtest.osnexus.net
IP.2 = 192.0.2.12
IP.1   = 10.0.12.201
IP.3 = 192.0.2.13
IP.2   = 10.0.12.202
IP.3   = 10.0.12.203
IP.4    = 10.0.12.205
IP.5    = 10.0.12.206
IP.6    = 10.0.12.207
</pre>
</pre>


=== Generate Server Key ===
Generate the private key, then the CSR:
 
This will generate a new server key we'll use to make a CSR from in the next step.


<pre>
<pre style="font-size: smaller">
openssl genrsa -out s3_adtest_osnexus_net.key 2048
openssl genrsa -out s3.key 2048
openssl req -new -key s3.key -config openssl.cnf -out s3.csr
</pre>
</pre>


=== Generate Certificate Signing Request (CSR) ===
Check the CSR before you submit it. The output should show your subject and, under {{Code|1=Subject Alternative Name}}, every name you listed:
 
Here we use the server key with the openssl.cnf configuration file to generate a CSR:


<pre>
<pre style="font-size: smaller">
openssl req -new -out s3_adtest_osnexus_net.csr -key s3_adtest_osnexus_net.key -config openssl.cnf
openssl req -in s3.csr -noout -text
</pre>
</pre>


=== Verify / Validate CSR ===
Keep {{Code|1=s3.key}} private. Anyone who has it can pose as your S3 service.
Next review the generated CSR to ensure it accurately contains the correct settings:


<pre>
== Having the CSR signed ==
openssl req -in s3_adtest_osnexus_net.csr -noout -text
</pre>


=== Submit CSR to Certificate Authority ===
Submit {{Code|1=s3.csr}} to your CA and follow its process.


Next take the CSR and submit it to your Certificate Authority. Refer to the Certificate Authorities documentation for signing the CSR and generating a server cert and CA chain. For Windows AD/Certificate Authority, install and deploy the Windows Certificate Authority role with the Certificate Authority web portal options. This should give you a new path to submit CSRs to under http://<AD Server IP>/certsrv
Download the signed certificate and the CA chain. A CA can supply them as Base64 (PEM) text or as binary DER files, often a {{Code|1=.cer}} file for the certificate and a {{Code|1=.p7b}} file for the chain.


Follow the onscreen prompts on the Windows Active Directory (AD) Certificate Authority page to submit the CSR and request a signed certificate. When the certificate is available for download you can download it in DER format (X. 509 digital certificate encoded in binary) or in Base64 format.  If you download it in DER format we can convert it after the fact.
== Converting the CA's files to PEM ==


If the .cer file is already in base64 encoded PEM format, you can simply rename it to .pem or proceed to the next step.
If the chain arrived as a {{Code|1=.p7b}} file, extract its certificates as PEM text:


=== Converting DER certificates to Base64 pem Format ===
<pre style="font-size: smaller">
 
openssl pkcs7 -print_certs -in certnew.p7b -inform DER -out chain.pem
This shows how to take a DER formatted file (certnew.p7b) to produce a certificate chain (cert_chain.pem) PEM file and a PRM file from the produced certificate (certnew.cer):
 
<pre>
openssl pkcs7 -print_certs -inform der -in certnew.p7b -out cert_chain.pem
openssl x509 -inform der -in certnew.cer -out certnew.pem
</pre>
</pre>


Next we'll rename the certificate authority chain file to a clearer name:
Leave out {{Code|1=-inform DER}} if the {{Code|1=.p7b}} file is Base64 text, which starts with {{Code|1=-----BEGIN PKCS7-----}}. The output also holds your server certificate when the CA included it. Build the PEM file from the certificates that issued yours, and check the order as described below.


<pre>
== Building the PEM file ==
cp cert_chain.pem adtest_osnexus_net.pem
</pre>


Next ensure your private key is now in PEM format, it should look like this in a text editor with BEGIN and END blocks showing the key in Base64 format:
Combine the key, the server certificate and the chain into one file, in that order:


<pre>
<pre style="font-size: smaller">
-----BEGIN PRIVATE KEY-----
cat s3.key > s3.pem
(Your private key here)
openssl x509 -in certnew.cer >> s3.pem
-----END PRIVATE KEY-----
cat chain.pem >> s3.pem
</pre>
</pre>


If your private key is in DER format, convert it to PEM using the following command:
{{Code|1=openssl x509}} reads the certificate whether the CA sent it as PEM text or as binary DER, and writes it as PEM text. Before you add the file to QuantaStor, run the checks in [[Certificate Template Manager#Checking the file|Checking the file]].


<pre>
== Applying the certificate ==
openssl rsa -inform DER -outform PEM -in derformat.key -out s3_adtest_osnexus_net.key
</pre>
 
Replace `derformat.key` with the path to your DER-formatted private key and `s3_adtest_osnexus_net.key` with the desired output filename for the PEM-formatted private key.
 
=== Concatenate the Private Key, Certificate, and Chain ===


You want to have the private key at the beginning of your PEM file followed by your certificate and then the certificate chain. Use the `cat` command to concatenate them in this order:
* '''New object gateways.''' The [[Add S3 Gateway To Ceph Cluster]] dialog has a '''Certificate (PEM)''' field. Select {{Code|1=s3.pem}} there. If you leave it empty, QuantaStor creates a self-signed certificate for the gateway.
* '''Existing object gateways and the load balancer.''' Add {{Code|1=s3.pem}} as a template and apply it with Update, as described on [[Certificate Template Manager]].


<pre>
== Trusting the CA on clients ==
cat s3_adtest_osnexus_net.key certnew.pem cert_chain.pem > s3_adtest_osnexus_net.pem
</pre>
 
Replace `myprivatekey.pem` with your private key file, `certnew.pem` with your certificate file, and `cert_chain.pem` with your certificate chain file. The combined file `combined_with_key.pem` will contain all three components.


=== Verify the Contents ===
Clients have to trust the CA that signed the certificate. A public CA is usually trusted already. For a private CA, add its root certificate to each client's trust store. On Ubuntu and Debian, save the root certificate as a file ending in {{Code|1=.crt}}:


You can check the contents of the final PEM file to ensure all parts are included correctly:
<pre style="font-size: smaller">
 
cp example-root-ca.crt /usr/local/share/ca-certificates/
<pre>
update-ca-certificates
openssl x509 -in s3_adtest_osnexus_net.pem -text -noout
</pre>
</pre>


This command will display the certificate details. You won't be able to view the private key this way (and you shouldn't be able to), but you can open the PEM file in a text editor to ensure the private key and certificates are present.
An S3 application that keeps its own trust store needs the CA added to that store as well. See the application's documentation.
 
=== Applying Cert at Creation of S3 Gateways ===
 
When creating new S3 Gateways in QuantaStor there's an option to provide a PEM file at that time and there you'll want to specify the 's3_adtest_osnexus_net.pem' file you've generated.


=== Applying Cert to Existing S3 Gateways ===
== Testing from a client ==


Copy your certificate to '''/etc/ceph/ceph_<HOSTNAME>_radosgw.pem''' where <HOSTNAME> needs to be replace with the local host hostname which you can also get by running 'hostname' then restart the S3 gateway (radosgw) services with this command:
From a client that trusts the CA, check the certificate the load balancer serves:


<pre>
<pre style="font-size: smaller">
systemctl restart ceph-radosgw@*.service
echo | openssl s_client -connect s3.example.com:8580 -servername s3.example.com 2>&1 | grep -E 'subject=|Verify return code'
</pre>
</pre>


=== Updating Clients ===
You should see your certificate's subject and {{Code|1=Verify return code: 0 (ok)}}. Port 8580 is the load balancer. Use port 7480 to test an object gateway directly.
 
On your S3 client systems/hosts insert the CA's cert chain file if not already present. For example, on a Ubuntu 20.04 based system you can use the following commands to add the cert chain:
 
<pre>
cp adtest_osnexus_net.pem /usr/local/share/ca-certificates/
update-ca-certificates
</pre>


Note, you may need to break the cert file up into separate files depending on the length of the cert chain. 
== Related pages ==


=== Test the Certificate ===
* [[Certificate Template Manager]]
* [[Add Certificate Template]]
* [[Update Certificates]]
* [[Add S3 Gateway To Ceph Cluster]]


Finally, it is important to test the certificate from a client to verify it via openssl to ensure there are no configuration errors or other issues. The '''curl''' and openssl utilities for both good for this:
----
 
<small>''Verified against QuantaStor 6.9.0.''</small>
<pre>
curl https://<FQDN of server>:<port>
 
echo -n | openssl s_client -showcerts -connect <FQDN of server>:<port>
</pre>

Latest revision as of 12:15, 25 November 2026

This page shows how to create a private key and certificate signing request (CSR) for the object storage (S3) service with OpenSSL, have your certificate authority (CA) sign it, and turn the result into the PEM file QuantaStor uses. To apply the finished file to the systems, see Certificate Template Manager.

Create the certificate before you deploy the object gateways if you can, so you can give it to the gateways when you create them.

Choosing the names

Clients check that the name they connect to appears in the certificate's Subject Alternative Name (SAN) list. Include:

  • the S3 endpoint name clients use, for example s3.example.com,
  • a wildcard for that name, for example *.s3.example.com, if clients put the bucket name in the host name (virtual-hosted style),
  • each system's own name, if clients connect to systems directly,
  • any IP address clients connect to.

QuantaStor refuses a certificate that has no SAN.

Creating the key and CSR

Work in an empty directory:

mkdir s3_cert
cd s3_cert

Create a file named openssl.cnf. Change the values under [ req_distinguished_name ] to your organisation's, and list your names under [ alt_names ]:

[ req ]
default_bits       = 2048
prompt             = no
default_md         = sha256
distinguished_name = req_distinguished_name
req_extensions     = req_ext

[ req_distinguished_name ]
C  = US
ST = Washington
L  = Bellevue
O  = Example Organization
OU = Storage
CN = s3.example.com

[ req_ext ]
subjectAltName = @alt_names

[ alt_names ]
DNS.1 = s3.example.com
DNS.2 = *.s3.example.com
DNS.3 = qs-node1.example.com
DNS.4 = qs-node2.example.com
DNS.5 = qs-node3.example.com
IP.1  = 192.0.2.11
IP.2  = 192.0.2.12
IP.3  = 192.0.2.13

Generate the private key, then the CSR:

openssl genrsa -out s3.key 2048
openssl req -new -key s3.key -config openssl.cnf -out s3.csr

Check the CSR before you submit it. The output should show your subject and, under Subject Alternative Name, every name you listed:

openssl req -in s3.csr -noout -text

Keep s3.key private. Anyone who has it can pose as your S3 service.

Having the CSR signed

Submit s3.csr to your CA and follow its process.

Download the signed certificate and the CA chain. A CA can supply them as Base64 (PEM) text or as binary DER files, often a .cer file for the certificate and a .p7b file for the chain.

Converting the CA's files to PEM

If the chain arrived as a .p7b file, extract its certificates as PEM text:

openssl pkcs7 -print_certs -in certnew.p7b -inform DER -out chain.pem

Leave out -inform DER if the .p7b file is Base64 text, which starts with -----BEGIN PKCS7-----. The output also holds your server certificate when the CA included it. Build the PEM file from the certificates that issued yours, and check the order as described below.

Building the PEM file

Combine the key, the server certificate and the chain into one file, in that order:

cat s3.key > s3.pem
openssl x509 -in certnew.cer >> s3.pem
cat chain.pem >> s3.pem

openssl x509 reads the certificate whether the CA sent it as PEM text or as binary DER, and writes it as PEM text. Before you add the file to QuantaStor, run the checks in Checking the file.

Applying the certificate

  • New object gateways. The Add S3 Gateway To Ceph Cluster dialog has a Certificate (PEM) field. Select s3.pem there. If you leave it empty, QuantaStor creates a self-signed certificate for the gateway.
  • Existing object gateways and the load balancer. Add s3.pem as a template and apply it with Update, as described on Certificate Template Manager.

Trusting the CA on clients

Clients have to trust the CA that signed the certificate. A public CA is usually trusted already. For a private CA, add its root certificate to each client's trust store. On Ubuntu and Debian, save the root certificate as a file ending in .crt:

cp example-root-ca.crt /usr/local/share/ca-certificates/
update-ca-certificates

An S3 application that keeps its own trust store needs the CA added to that store as well. See the application's documentation.

Testing from a client

From a client that trusts the CA, check the certificate the load balancer serves:

echo | openssl s_client -connect s3.example.com:8580 -servername s3.example.com 2>&1 | grep -E 'subject=|Verify return code'

You should see your certificate's subject and Verify return code: 0 (ok). Port 8580 is the load balancer. Use port 7480 to test an object gateway directly.

Related pages


Verified against QuantaStor 6.9.0.