Aug 22

OpenVPN between pfSense and Mikrotik

Reading time: 3 – 5 minutes

vpn-pfsense-mikrotik-schemaAssuming previous scenario I’m going to describe the required configurations on pfSense and Mikrotik. Certifcate creation is not part of the scope of this document, if you are not familiar about how to do that it’s a good idea to use the pfSense certificate manager to do it. My last advice is take care with certificates 90% of problems that I found in my life when I was working on VPNs are because of that. Take your time to check it before spend your time playing with other configurations.

In that scenario pfSense will play the role of the VPN server and Mikrotik will be the client, so I’m going to start describing pfSense configurations.

Create OpenVPN server on proper section:

pfsense-openvpn-server

 

Important things to take in account when you set up the parameters are socket has to be a TCP socket in my case I decided to use port 1201:

pfsense-openvpn-server-configNext settings on the same place are about local network and tunnel IP addresses, this is required to create proper routing rules on the server and the client.

pfsense-openvpn-server-config2

 

Last part to configure on this sections is extremly simple, only take care to unmark everything and check “address pool” setting.

pfsense-openvpn-server-config3

 

Remember to open that port on Firewall rules.

pfsense-firewall-rules

 

A VPN user is required to authenticate the process, just go to “User Management” inside the “System” menu:

pfsense-user-manager-oriol

 

pfSense is configured, now it’s time to set-up the OpenVPN client on Mikrotik using Winbox. Remember to import the certificates:

certificates-mikrotik

 

Click on “PPP” this on the left menu:

ppp-mikrotik

 

Add an OVPN Client connection using the “+” button, the parameters for that connection are:

ppp-interface

 

Another required thing to define on “PPP” is the profile, click on the tab “Profile” and using the button with symbol “+” create a new profile like that:

ppp-profile

 

Everything is ready, now it’s time to check if the connection is OK. First go to the OVPN client on Mikrotik, remember this is on “PPP” menu option and inside tab “Interfaces”. Clicking on the interface you’ll see the status details. If it’s disconnect going to pfSense or Mikrotik logs you can see the negotiation details.

Remember usually the problem is with your certificates, but first of all you have to ensure that the negotiation tries to start.

Enjoy it and good luck.

 

Aug 01

Extracting private and public keys from a p12 file

Reading time: 1 – 2 minutes

PKCS#12 is a container for storing many cryptography objects as a single file. It is commonly used to bundle a private key with its X.509 certificate or to bundle all the members of a chain of trust. This is a fast and simple summary about how to extract your keys from those kind of files:

#Private key:
openssl pkcs12 -in file_name.p12 -nocerts -out private.key
#Certificates:
openssl pkcs12 -in file_name.p12 -clcerts -nokeys -out public.crt

Recurrently I have to access to a usuful guide about those kind of openssl parameters, let me refer that guide:

The Most Common OpenSSL Commands (local copy)

Update 2016/09/19
Usefull links for SSL:

Feb 26

gnoMint: X.509 CA management tool

Reading time: 2 – 3 minutes

Quan administres alguns sistemes i comences a montar serveis SSL arriba un moment que acabes familiaritzan-te amb la sintaxis d’openSSL per la generació de certificats i fins hi tot entitats certificadores autosignades. El problema és quan has de mantenir diverses entitats i diversos certificats arriba un moment que ja no recordes a quina màquina tens els fitxers guardas i l’administració de tot plegat es fa força pesat.

Així doncs, m’he decidit a provar gnoMint que eś una eina programada amb GTK i que fa de GUI a les típiques funcioalitats que demanem sovint al openSSL. Així doncs, és molt senzill de crear diverses entitats certificadores amb diversos certificats associats a cada una d’elles. Però el més important és senzillissim de mantenir, ja que en un cop d’ull saps quins certificats tens creats i quins et caldran per un nou projecte. A més de poder exportar les claus publiques i privades de forma ben senzilla.

Un petit resum de funcionalitats de l’eina seria el que trobem a la seva web:

  • Creating all the infrastructure to keep and run a Certification Authority, saved in only one file.
  • Create Certification Signing Requests, allowing to export them to PKCS#8 files, so they can be send to other CAs.
  • Create X.509 certificates, with a usual set of subject-parameters.
  • Export certificates and private keys to PEM files, so they can be used by external applications.
  • For each CA, establish a set of policies for certificate generation.
  • Import CSRs made by other applications
  • Export PKCS#12 structures, so the certificates can be imported easily by web and mail clients.
  • Revoke certificates, and generate the corresponding CRLs
  • Allow the possibility of keeping the CA private key, or other private keys, in external files or devices (as USB drives)
  • Allow the management of a whole hierarchy of CAs, with their respectives certificates.
  • Import pre-existing Certification Authorities, with all their data.
  • Allow an easy CA operation from command-line tools, for batch certificate creation, or integration with other utilities.