Posts

Showing posts with the label HTTPS

Load test your API with Vegeta

Image
Load test your API with Vegeta Vegeta is a open source HTTP load testing tool. Today I’ll demonstrate how quickly and easily we can load test our API endpoint using it in three parts: Get Vegeta Setup a target file Generate reports 1. Get Vegeta Vegeta binaries are available on GitHub Releases . For Windows, all we need to do is to get the Windows executable and unzip it for example under C:\vegeta . The vegeta.exe is the executable we will be using. To make sure it works as expected, we can display the usage guide by execute vegeta.exe without any arguments. > vegeta.exe Usage: vegeta [global flags] <command> [command flags] global flags: -cpus int Number of CPUs to use (default 4) -profile string Enable profiling of [cpu, heap] -version Print version and exit attack command: -body string Requests body file -cert string ... The main concept of Vegeta are the targets . A target represents an endpoint which will be load...

Setup HTTPS with Nginx on Azure Ubuntu VM

Image
Setup HTTPS with Nginx on Azure Ubuntu VM Today we will see how we can setup HTTPS on using Certbot Nginx configuration on an Azure Ubuntu VM. This post will be composed of three steps: Prepare the VM Install Nginx Install Certbot 1. Prepare the VM We start first by creating an Azure VM on Ubuntu 18.04 with either password or SSH and allowing HTTP , HTTPS , SSH . Once done, we can select a custom DNS for our VM. This makes it easier to SSH but also it will be required for our SSL certificate setup. We set the Assignment as Static then we choose a DNS name label. Here we choose azure-test-vm therefore the VM will be accessible at azure-test-vm.southcentralus.cloudapp.azure.com . We should now be able to SSH into the VM using the command: ssh kimserey@azure-test-vm.southcentralus.cloudapp.azure.com 2. Install Nginx Next once we are in the VM, we can install Nginx by installing the following: sudo apt-get update sudo apt-get install nginx Once installed, as we already h...

Nginx 502 bad gateway after SSL setup

Nginx 502 bad gateway after SSL setup When proxying a request to an underlying server, it is necessary to validate its SSL certificate. For example, if we have a process running on https://localhost:5001 , we can configure Nginx to validate the certificate used by localhost:5001 . But if we miss one step, we face the common error 502 Bad Gateway returned by Nginx. Today we will see two scenarios where we can face the error and how to fix them: Setup SSL verification Scenario 1: self-signed certificate Scenario 2: upstream server 1. Setup SSL verification We can tell Nginx to verify the underlying SSL by adding the following directives, either on server or location level: server { // ... more config proxy_ssl_trusted_certificate /etc/ssl/certs/ca-certificates.crt; proxy_ssl_verify on; proxy_ssl_session_reuse on; location / { proxy_pass https://localhost:5001/; } } proxy_ssl_trusted_certificate indicates to Nginx the location of the trusted CA certificates...

HTTPS with SSL for Nginx, Kestrel and Angular

HTTPS with SSL for Nginx, Kestrel and Angular Internet is moving toward secure connections whereby HTTPS is a priority. Browsers are now warning users when navigating to non secured website. With this movement, Kestrel and ASPNET Core have adopted the mentality of security by default rather than security when needed. HTTPS will now be the default and HTTP will be a necessity due to implementation constraints. Together with Lets Encrypt and ACME protocol, we do not have excuses for not implementing an SSL connection. Setup the example SSL self signed certificate for Nginx SSL self signed certificate for Kestrel SSL self signed certificate for Angular CLI 1. Setup the example We assume that our environment is on Ubuntu, with nginx and dotnet installed. If you are on Windows, you can install the linux subsystem with Ubuntu 16.04 as describe on my previous post . This will give access to most of the features of Ubuntu via a bash prompt. To start we create a HelloWorld applicatio...

A complete SignalR with ASP Net Core example with WSS, Authentication, Nginx

SignalR with ASP Net Core SignalR is a framework from ASP NET Core allowing us to establish a two way communication between client and server. This two way communication allows the client to send messages to the server but more importantly allows the server to push messages to the client. SignalR makes use of Websocket when available else it falls back to SSE or pulling. Today we will focus on how to setup SignalR to work with WSS, Websocket secure and how we can authenticate the user requesting to connect to our SignalR hub via Webscoket. Getting started with SignalR SSL encryption for Websocket Secure WSS Websocket Authentication with Identity Server 4 SignalR behind Nginx 1. Getting started with SignalR The Hubs are the main components of SignalR. It is an abstraction of a two way communication available for both client and server. Public functions from the hub can be called from the server code and can be called from the client. The frontend NPM package @aspnet/signalr ...

Remove redirection of localhost to HTTPS

Remove redirection of localhost to HTTPS Symptoms Chrome redirects http://localhost to https://localhost On guest mode, http://localhost is accessible Curl can retrieve http://localhost Cause One of my test project was configuring SSL on nginx. The configuration was redirecting localhost to https for testing purposes and Chrome had since then cached the redirection. Subsequent calls were no longer hitting nginx as they were only hitting Chrome cache. Fix Open the Web Developer Console on Chrome, CTRL+SHIFT+I Right click on the reload arrow Select Empty Cache And Hard Reload This will remove all cached items including the redirection. http://localhost will no longer be redirected by Chrome.

Self Signed Certificate for Identity Server 4 and SSL in Ubuntu 16.04 server

Image
Self Signed Certificate for Identity Server 4 and SSL in Ubuntu 16.04 server To sign our JWT tokens, Identity Server 4 requires a signing credential. Today we will see how we can create our own key and provide it to Identity Server to be used as signing credential. Configure ASP NET Core Create key with openssl Selfsigned certificate for local SSL usage If you are new to Identity Server, you can have a look at my previous blog post on How to configure a Implicit authentication with Identity Server . 1. Configure ASP NET Core We start first by creating an extension on top of the IIdentityServerBuilder which when the key is available, will load our own key using the .AddSigningCredential() else will create a temporary key for development purposes, .AddDeveloperSigningCredential() . public static class IdentityServerBuilderExtensions { public static IIdentityServerBuilder LoadSigningCredentialFrom(this IIdentityServerBuilder builder, string path) { if (!string...