-
Home
- Configuration Security 2
Security Settings
Customizing TLS Certificates
You can use your own certificate to secure the communications between the Hardware Sentry Agent and the OpenTelemetry Collector by replacing the default TLS certificate of the OTLP gRPC Receiver.
Prerequisites
- The certificate file must be in PEM format and can contain one or more certificate chains. The first certificate compatible with the client's requirements will be automatically selected.
- The private key must be nonencrypted and in PEM format.
- The certificate must include the
subjectAltNameextension indicatingDNS:localhost,IP:127.0.0.1because internal communications are onlocalhostonly and the Hardware Sentry Agent'sOTLP Exporterperforms hostname verification.
Procedure
-
Generate your new private key and certificate files (for example:
my-otel.keyandmy-otel.crt). -
Copy the generated certificate and private key files into the
securitydirectory. -
In the
otel/otel-config.yamlfile, update thetls:cert_fileandtls:key_fileattributes of theOTLP gRPC Receiver:receivers: otlp: protocols: grpc: endpoint: localhost:4317 tls: cert_file: ../security/my-otel.crt # Your new certificate file. key_file: ../security/my-otel.key # Your new private key file. auth: authenticator: basicauth -
In the
config/hws-config.yamlfile, set your new certificate (security/my-otel.crt) astrustedCertificatesFilein theOTLP Exporterconfiguration section:exporter: otlp: trustedCertificatesFile: /opt/hws/security/my-otel.crt # Your new OTLP gRPC Receiver certificate. hosts: # ... -
Restart Hardware Sentry. See Installation for more details.
Generating a Self-Signed Certificate with OpenSSL (Example)
OpenSSL is a command line tool to generate X.509 certificates. It can be used to generate Self-Signed Certificates.
The example below explains how to generate a server certificate using the OpenSSL utility on a Linux machine. Your organization may define its own security policy to handle certificates and private keys. Before proceeding further, make sure that this procedure is right for your organization.
-
Create a private key for the Certificate Authority (CA):
$ openssl genrsa 2048 > ca.key -
Generate the X.509 certificate for the CA:
$ openssl req -new -x509 -nodes -days 365000 \ -key ca.key \ -out ca.crt -
Generate the private key and certificate request:
$ openssl req -newkey rsa:2048 -nodes -days 365000 \ -keyout my-otel.key \ -out my-otel.req -
Generate the X.509 certificate for the
OTLP gRPC Receiver:$ openssl x509 -req -days 365000 -set_serial 01 \ -in my-otel.req \ -out my-otel.crt \ -CA ca.crt \ -CAkey ca.key \ -extfile cert.conf -extensions req_extWhere the
cert.conffile defines the extension to add to your certificate:[ req ] req_extensions = req_ext [ req_ext ] subjectAltName = DNS:localhost,IP:127.0.0.1 -
Your certificate (
my-otel.crt) and private key (my-otel.key) are now generated in PEM format. You can verify your certificate as follows:$ openssl verify -CAfile ca.crt \ ca.crt \ my-otel.crt
Customizing OTLP Authentication Password
You can use your own paswword to have the OTLP gRPC Receiver authenticate any incoming request.
Prerequisites
Access to the htpasswd tool:
- On a Linux system, you can install the
httpd-toolspackage. - On a Windows system, the
htpasswdutility is embedded in one of the packages listed in the Downloading Apache for Windows page.
Procedure
-
Create a new
.htpasswd-otelfile using your username and password:$ htpasswd -cbB .htpasswd-otel myUsername myPassword Adding password for user myUsername -
Copy the
.htpasswd-otelfile into thesecuritydirectory. -
In the
otel/otel-config.yamlfile, update thefileattribute of thebasicauthextension:extensions: # ... basicauth: htpasswd: file: ../security/.htpasswd-otel # Your new htpasswd file -
In the
otel/otel-config.yamlfile:- make sure the
basicauthis declared as a service extension :
service: # ... extensions: [health_check, basicauth] # basicauth is added to the extensions list pipelines: # ...- make sure the
basicauthextension is declared asOTLP gRPC Receiverauthenticator:
receivers: otlp: protocols: grpc: # ... auth: authenticator: basicauth - make sure the
-
Generate a
base64string using the same credentials provided to generate the.htpasswd-otelfile. Join your username and password with a colonmyUsername:myPassword, and then encode the resulting string inbase64.$ echo -n 'myUsername:myPassword' | base64 bXlVc2VybmFtZTpteVBhc3N3b3Jk -
In the
otel/otel-config.yamlfile, add a newAuthorizationheader under theexporter:otlp:headerssection:exporter: otlp: headers: # ... Authorization: Basic bXlVc2VybmFtZTpteVBhc3N3b3Jk # Basic <base64-credentials>The
Authorizationheader must be provided asBasic <base64-credentials>, where<base64-credentials>is thebase64value you have generated in the previous step. -
Restart Hardware Sentry.
Disabling TLS (Not recommended)
When you disable TLS on Hardware Sentry, the communications between the Hardware Sentry Agent and the OpenTelemetry Collector are not encrypted anymore.
-
In the
otel/otel-config.yamlfile, remove or comment out thetlssection from theOTLP gRPC Receiverconfiguration:receivers: otlp: protocols: grpc: endpoint: localhost:4317 #tls: # No TLS # cert_file: ../security/my-otel.crt # key_file: ../security/my-otel.key auth: authenticator: basicauth -
In the
config/hws-config.yamlfile, update theOTLP Exporterendpoint to enableHTTP:exporter: otlp: endpoint: http://localhost:4317 hosts: # ... -
Remove or comment out the
trustedCertificatesFileattribute of theOTLP Exporterin theconfig/hws-config.yamlfile:exporter: otlp: endpoint: http://localhost:4317 # trustedCertificatesFile: security/otel.crt hosts: # ... -
Restart Hardware Sentry.
Disabling Authentication (Not Recommended)
If you disable the authentication on Hardware Sentry, incoming requests will no longer be authenticated by the OpenTelemetry Collector's OTLP gRPC Receiver and might expose you to malicious attacks.
-
In the
otel/otel-config.yamlfile, remove or comment out theauthsection from theOTLP gRPC Receiverconfiguration:receivers: otlp: protocols: grpc: endpoint: localhost:4317 tls: cert_file: ../security/my-otel.crt key_file: ../security/my-otel.key # auth: # authenticator: basicauth # No authentication -
In the
otel/otel-config.yamlfile, remove thebasicauthextension from the service extensions list:service: # ... extensions: [health_check] # basicauth is not added to the extensions list pipelines: # ... -
In the
config/hws-config.yamlfile, remove or comment out theAuthorizationheader from theOTLP Exporterconfiguration:exporter: otlp: trustedCertificatesFile: /opt/hws/security/otel.crt headers: # Authorization: Basic bXlVc2VybmFtZTpteVBhc3N3b3Jk # Basic <base64-credentials> hosts: # ... -
Restart Hardware Sentry.