Wednesday, March 13, 2024

Remove both commented lines and empty lines from a HOCON file

To remove both commented lines and empty lines from a HOCON file, combine `grep` and `sed` commands like so:

grep -vE '^\s*(#|$)' <filename> | sed '/^\s*$/d'


- `grep -vE '^\s*(#|$)' <filename>`: This `grep` command filters out lines that are entirely empty or start with optional whitespace (`\s*`) followed by a `#` character (indicating a comment) or are entirely empty (`$`).

- `sed '/^\s*$/d'`: This `sed` command removes lines that are entirely empty. `/^\s*$/` matches lines that contain only optional whitespace characters followed by the end of the line (`$`). The `d` command then deletes these lines.

Replace `<filename>` with the name of your HOCON file.

***

Saturday, March 2, 2024

Update own Certificate Authority (CA) as a trusted CA on your OS

 1) On Ubuntu/Debian

Move your own CA certificate to "/etc/ssl/certs/"

or "/usr/local/share/ca-certificates/ca.crt"

Once moved run below command to update

$ sudo update-ca-certificates


Reference: https://manpages.debian.org/buster/ca-certificates/update-ca-certificates.8.en.html


2) On Oracle Linux/Fedora

Move your own CA certificate to "/etc/pki/ca-trust/source/anchors/"

or "/usr/share/pki/ca-trust-source/anchors/"


Once moved run below command to update

$ sudo update-ca-trust


Reference: https://docs.fedoraproject.org/en-US/quick-docs/using-shared-system-certificates/


3) On Windows

Assuming the path to your generated CA certificate as C:\ca.pem, run:


Import-Certificate -FilePath "C:\ca.pem" -CertStoreLocation Cert:\LocalMachine\Root

Set -CertStoreLocation to Cert:\CurrentUser\Root in case you want to trust certificates only for the logged in user.

OR


In Command Prompt, run:


certutil.exe -addstore root C:\ca.pem

certutil.exe is a built-in tool (classic System32 one) and adds a system-wide trust anchor.


4) On Android

Settings ==> Security & Privacy ==> More security & Privacy ==> Encryption and Credentials

Select "Install a certificate" ==> CA certificate ==> Install certificate


***