Skip to main content

Posts

Showing posts from February, 2023

Creating Self-signed and CA Certificate using OpenSSL

A self-signed certificate is very useful for us when we are in a development or closed environment and require a secure communication channel between nodes in our system like implementing HTTPS for client-server communication. To make our self-signed certificate to be recognized by all nodes in the system, we should generate the CA certificate and distribute it to all nodes. This CA certificate is used to verify and determine the issuer of the self-signed certificate. It is like a stamp on a certificate that ensures the certificate is issued by the authority informed in the certificate itself. OpenSSL CLI tool will be used for this purpose. The following steps can be run to generate valid self-signed and CA certificates. Generate a private CA key Generate a public CA certificate Generate a private key for the target server Generate a CSR for the server Generate a public server certificate and sign it with the CA certificate Before we start the certificate generatio

Managing Kubernetes Cluster in Ubuntu

There are several tools and services in the market that we can use to deploy and manage Kubernetes clusters. Some tools allow us to self-manage the cluster without charge, some require us to subscribe for the license, and some services are provided as a Kubernetes as a Service such as Amazon EKS and Red Hat OpenShift Dedicated. For development purposes or small-scale service, there is a free tool to manage Kubernetes clusters named minikube which is available for Windows, Linux, and MacOS. To build the cluster, Minikube supports several virtualization technologies such as Hypervisor, KVM, Docker, and so on. In this writing, we will try to utilize Docker as the virtualization solution and run it in Ubuntu 22.04. In general, we will run through the following steps. Install Minikube Install Docker Allow a non-root user to access Docker Start Minikube Enable Ingress extension Install Kubectl Install Minikube First, we need to install Minikube's depen

Detecting Main Module in ESM Package

ESM package works in a different fashion from CJS. ESM package imports required modules asynchronously and have no support for several functions related to system files and directories. ESM follows Javascript cores that are implemented in the browser. There is no such entity like __dirname , __filename , require() , and so on. If we want to detect whether a module is a main module that is being run in CJS, we can compare the value of require.module and module . If it is the same, the module is being run as the main module. Meanwhile, for a module in the ESM package, we can use the following approach. Get the value of process.argv[1] that contains information of the main file that is being called by Node. Get the value of import.meta.url that contains information of the module's location that is being accessed. Transform the information to have a similar format, then compare it. For example, we have a module in an ESM package, named module1.js . import { r