Skip to content

Commit 8488085

Browse files
authored
Merge pull request #270142 from cherylmc/openssl2
New article
2 parents 3f946ed + 6d43532 commit 8488085

File tree

3 files changed

+79
-2
lines changed

3 files changed

+79
-2
lines changed

articles/vpn-gateway/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@
143143
href: vpn-gateway-certificates-point-to-site.md
144144
- name: Makecert
145145
href: vpn-gateway-certificates-point-to-site-makecert.md
146+
- name: Linux - OpenSSL
147+
href: point-to-site-certificates-linux-openssl.md
146148
- name: Linux - strongSwan
147149
href: vpn-gateway-certificates-point-to-site-linux.md
148150
- name: RADIUS authentication
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
---
2+
title: 'Generate and export certificates for point-to-site: Linux - OpenSSL'
3+
description: Learn how to create a self-signed root certificate, export the public key, and generate client certificates using OpenSSL.
4+
titleSuffix: Azure VPN Gateway
5+
author: cherylmc
6+
ms.service: vpn-gateway
7+
ms.topic: how-to
8+
ms.date: 03/25/2024
9+
ms.author: cherylmc
10+
11+
---
12+
# Generate and export certificates - Linux - OpenSSL
13+
14+
VPN Gateway point-to-site (P2S) connections can be configured to use certificate authentication. The root certificate public key is uploaded to Azure and each VPN client must have the appropriate certificate files installed locally in order to connect. This article helps you create a self-signed root certificate and generate client certificates using OpenSSL. For more information, see [Point-to-site configuration - certificate authentication](vpn-gateway-howto-point-to-site-resource-manager-portal.md).
15+
16+
## Prerequisites
17+
18+
To use this article, you must have a computer running OpenSSL.
19+
20+
## Self-signed root certificate
21+
22+
This section helps you generate a self-signed root certificate. After you generate the certificate, you export root certificate public key data file.
23+
24+
1. The following example helps you generate the self-signed root certificate.
25+
26+
```CLI
27+
openssl genrsa -out caKey.pem 2048
28+
openssl req -x509 -new -nodes -key caKey.pem -subj "/CN=VPN CA" -days 3650 -out caCert.pem
29+
```
30+
31+
1. Print the self-signed root certificate public data in base64 format. This is the format that's supported by Azure. Upload this certificate to Azure as part of your [P2S configuration](vpn-gateway-howto-point-to-site-resource-manager-portal.md#uploadfile) steps.
32+
33+
```CLI
34+
openssl x509 -in caCert.pem -outform der | base64 -w0 && echo
35+
```
36+
37+
## Client certificates
38+
39+
In this section, you generate the user certificate (client certificate). Certificate files are generated in the local directory in which you run the commands. You can use the same client certificate on each client computer, or generate certificates that are specific to each client. It's crucial is that the client certificate is signed by the root certificate.
40+
41+
1. To generate a client certificate, use the following examples.
42+
43+
```CLI
44+
export PASSWORD="password"
45+
export USERNAME=$(hostnamectl --static)
46+
47+
# Generate a private key
48+
openssl genrsa -out "${USERNAME}Key.pem" 2048
49+
50+
# Generate a CSR (Certificate Sign Request)
51+
openssl req -new -key "${USERNAME}Key.pem" -out "${USERNAME}Req.pem" -subj "/CN=${USERNAME}"
52+
53+
# Sign the CSR using the CA certificate and CA key
54+
openssl x509 -req -days 365 -in "${USERNAME}Req.pem" -CA caCert.pem -CAkey caKey.pem -CAcreateserial -out "${USERNAME}Cert.pem" -extfile <(echo -e "subjectAltName=DNS:${USERNAME}\nextendedKeyUsage=clientAuth")
55+
```
56+
57+
1. To verify the client certificate, use the following example.
58+
59+
```CLI
60+
openssl verify -CAfile caCert.pem caCert.pem "${USERNAME}Cert.pem"
61+
```
62+
63+
## To use this client certificate on another Linux computer
64+
65+
Each client computer requires two files in order to authenticate:
66+
67+
* The file that contains the client key: caKey.pem
68+
* The file that contains the certificate public data: caCert.pem
69+
70+
Copy both of these files and transfer them to the Linux client computer.
71+
72+
## Next steps
73+
74+
To continue configuration steps, see [Point-to-site certificate authentication](vpn-gateway-howto-point-to-site-resource-manager-portal.md#uploadfile).

includes/vpn-gateway-p2s-rootcert-include.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
ms.topic: include
33
author: cherylmc
44
ms.service: vpn-gateway
5-
ms.date: 08/07/2023
5+
ms.date: 03/25/2024
66
ms.author: cherylmc
77
---
88
Obtain the .cer file for the root certificate. You can use either a root certificate that was generated with an enterprise solution (recommended), or generate a self-signed certificate. After you create the root certificate, export the public certificate data (not the private key) as a Base64 encoded X.509 .cer file. You upload this file later to Azure.
@@ -12,4 +12,5 @@ Obtain the .cer file for the root certificate. You can use either a root certifi
1212

1313
* [PowerShell instructions for Windows 10 or later](../articles/vpn-gateway/vpn-gateway-certificates-point-to-site.md): These instructions require PowerShell on a computer running Windows 10 or later. Client certificates that are generated from the root certificate can be installed on any supported P2S client.
1414
* [MakeCert instructions](../articles/vpn-gateway/vpn-gateway-certificates-point-to-site-makecert.md): Use MakeCert to generate certificates if you don't have access to a computer running Windows 10 or later. Although MakeCert is deprecated, you can still use it to generate certificates. Client certificates that you generate from the root certificate can be installed on any supported P2S client.
15-
* [Linux instructions](../articles/vpn-gateway/vpn-gateway-certificates-point-to-site-linux.md).
15+
* [Linux - OpenSSL instructions](../articles/vpn-gateway/point-to-site-certificates-linux-openssl.md)
16+
* [Linux - strongSwan instructions](../articles/vpn-gateway/vpn-gateway-certificates-point-to-site-linux.md)

0 commit comments

Comments
 (0)