Skip to content

Commit abd9199

Browse files
authored
Merge pull request #8185 from MicrosoftDocs/users/sdanie/478877
Pipelines agent - Verifying Root Certificate Authority Trust
2 parents 36a6dc7 + 2824a9b commit abd9199

File tree

1 file changed

+42
-23
lines changed

1 file changed

+42
-23
lines changed

docs/pipelines/agents/certificate.md

Lines changed: 42 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
22
title: Run the agent with a self-signed certificate
3-
description: Learn how to run the build and release agent with a self-signed certificate for Azure Pipelines and Team Foundation Server (TFS)
3+
description: Learn how to run the build and release agent with a self-signed certificate for Azure Pipelines and Azure DevOps Server
44
ms.topic: conceptual
55
ms.assetid: 09E36E4D-D94B-4F5B-BE4D-9E7B4E7B68E2
66
ms.reviewer: chrispat
7-
ms.date: 06/22/2023
7+
ms.date: 08/05/2025
88
monikerRange: '< azure-devops'
99
---
1010

@@ -14,9 +14,6 @@ monikerRange: '< azure-devops'
1414

1515
This topic explains how to run a self-hosted agent with a self-signed certificate.
1616

17-
> [!NOTE]
18-
> This article applies to agent versions 2.x and newer.
19-
2017
## Work with SSL server certificate
2118

2219
```
@@ -31,15 +28,15 @@ Agent diagnostic log shows:
3128
[2017-11-06 20:55:33Z ERR AgentServer] System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.Http.WinHttpException: A security error occurred
3229
```
3330

34-
This error may indicate the server certificate you used on your TFS server is not trusted by the build machine. Make sure you install your self-signed ssl server certificate into the OS certificate store.
31+
This security error may indicate the server certificate you used on your Azure Devops Server host machine isn't trusted by the build machine. Make sure you install your self-signed ssl server certificate into the OS certificate store.
3532
```
3633
Windows: Windows certificate store
3734
Linux: OpenSSL certificate store
3835
macOS: OpenSSL certificate store for agent version 2.124.0 or below
3936
Keychain for agent version 2.125.0 or above
4037
```
4138

42-
You can easily verify whether the certificate has been installed correctly by running few commands.
39+
You can easily verify whether the certificate is installed correctly by running few commands.
4340
You should be good as long as SSL handshake finished correctly even you get a 401 for the request.
4441
```
4542
Windows: PowerShell Invoke-WebRequest -Uri https://corp.tfs.com/tfs -UseDefaultCredentials
@@ -53,7 +50,7 @@ The agent version 2.125.0 or above has the ability to ignore SSL server certific
5350

5451
> [!IMPORTANT]
5552
>
56-
> This is not secure and not recommended, we highly suggest you to install the certificate into your machine certificate store.
53+
> Ignoring SSL server certificate validation errors isn't secure and not recommended, we highly suggest you install the certificate into your machine certificate store.
5754
5855
Pass `--sslskipcertvalidation` during agent configuration
5956
```
@@ -62,22 +59,23 @@ Pass `--sslskipcertvalidation` during agent configuration
6259

6360
> [!NOTE]
6461
>
65-
> There is limitation of using this flag on Linux and macOS
66-
> The libcurl library on your Linux or macOS machine needs to built with OpenSSL, [More Detail](https://github.com/dotnet/corefx/issues/9728)
62+
> To use the `--sslskipcertvalidation` flag on Linux and macOS,
63+
> the `libcurl` library on your Linux or macOS machine must be built with OpenSSL. [More information](https://github.com/dotnet/corefx/issues/9728)
6764
6865
### Git get sources fails with SSL certificate problem (Windows agent only)
66+
6967
We ship command-line Git as part of the Windows agent.
70-
We use this copy of Git for all Git related operation.
71-
When you have a self-signed SSL certificate for your on-premises TFS server, make sure to configure the Git we shipped to allow that self-signed SSL certificate.
72-
There are 2 approaches to solve the problem.
68+
We use this copy of Git for all Git related operations.
69+
When you have a self-signed SSL certificate for your on-premises Azure DevOps Server machine, make sure to configure the Git we shipped to allow that self-signed SSL certificate.
70+
There are two approaches to solve the problem.
7371

7472
1. Set the following git config in global level by the agent's run as user.
7573
```bash
7674
git config --global http."https://tfs.com/".sslCAInfo certificate.pem
7775
```
7876
> [!NOTE]
7977
>
80-
> Setting system level Git config is not reliable on Windows. The system .gitconfig file is stored with the copy of Git we packaged, which will get replaced whenever the agent is upgraded to a new version.
78+
> Setting system level Git config isn't reliable on Windows. The system `.gitconfig` file is stored with the copy of Git we packaged, which gets replaced whenever the agent is upgraded to a new version.
8179
8280
2. Enable git to use `SChannel` during configure with 2.129.0 or higher version agent
8381
Pass `--gituseschannel` during agent configuration
@@ -86,20 +84,20 @@ There are 2 approaches to solve the problem.
8684
```
8785
> [!NOTE]
8886
>
89-
> Git SChannel has more restrict requirement for your self-signed certificate.
90-
> Self-singed certificate that generated by IIS or PowerShell command may not be capable with SChannel.
87+
> Git `SChannel` has more restrict requirement for your self-signed certificate.
88+
> Self-signed certificate that generated by IIS or PowerShell command may not be capable with `SChannel`.
9189
9290
## Work with SSL client certificate
9391

94-
IIS has an SSL setting that requires all incoming requests to Azure DevOps Server or TFS must present client certificate in addition to the regular credential.
92+
IIS has an SSL setting that requires all incoming requests to Azure DevOps Server must present client certificate in addition to the regular credential.
9593

96-
When that IIS SSL setting enabled, you need to use `2.125.0` or above version agent and follow these extra steps in order to configure the build machine against your Azure DevOps or TFS server.
94+
When that IIS SSL setting enabled, you need to use version `2.125.0` or newer and follow these extra steps in order to configure the build machine against your Azure DevOps Server.
9795

9896
- Prepare all required certificate information
99-
- CA certificate(s) in `.pem` format (This should contain the public key and signature of the CA certificate, you need put the root ca certificate and all your intermediate ca certificates into one `.pem` file)
100-
- Client certificate in `.pem` format (This should contain the public key and signature of the Client certificate)
101-
- Client certificate private key in `.pem` format (This should contain only the private key of the Client certificate)
102-
- Client certificate archive package in `.pfx` format (This should contain the signature, public key and private key of the Client certificate)
97+
- CA certificate(s) in `.pem` format (This file should contain the public key and signature of the CA certificate, you need put the root ca certificate and all your intermediate ca certificates into one `.pem` file)
98+
- Client certificate in `.pem` format (This file should contain the public key and signature of the Client certificate)
99+
- Client certificate private key in `.pem` format (This file should contain only the private key of the Client certificate)
100+
- Client certificate archive package in `.pfx` format (This file should contain the signature, public key and private key of the Client certificate)
103101
- Use `SAME` password to protect Client certificate private key and Client certificate archive package, since they both have client certificate's private key
104102

105103
- Install CA certificate(s) into machine certificate store
@@ -118,5 +116,26 @@ When that IIS SSL setting enabled, you need to use `2.125.0` or above version ag
118116
macOS: macOS Keychain
119117
Windows: Windows Credential Store
120118
```
121-
119+
## Verifying Root Certificate Authority Trust
120+
The build agent utilizes Node.js that relies on its own certificate store derived from Mozilla's trusted root certificates. It's crucial that any root certificate used for secure communication is trusted by the Node.js Certificate Authority store, which helps avoid the following errors after updating a certificate on the Azure DevOps Server machine:
121+
- unable to get local issuer certificate
122+
- SELF_SIGNED_CERT_IN_CHAIN
123+
- unable to verify the first certificate
124+
125+
The tls.rootCertificates array can be used to verify trusted root Certificate Authorities (CAs) used for verifying TLS/SSL connections.
126+
```bash
127+
# Sample script to extract Node.js root certificates using Node.js.
128+
node -e '
129+
const tls = require("tls");
130+
console.log(tls.rootCertificates.join("\n"));
131+
' > "$ROOT_CERTS_FILE"
132+
```
133+
To configure Node.js to trust a certificate
134+
NODE_EXTRA_CA_CERTS environment variable, introduced in Node v7.3.0, allows you to specify a file containing one or more additional CA certificates that Node will trust in addition to the default bundle. NODE_EXTRA_CA_CERTS appends to the trust store.
135+
1. Export the certificate(s) in PEM format: On your server or CA, export the root (and any intermediate, if needed) certificates as a PEM encoded file. This format is a text file with -----BEGIN CERTIFICATE----- and base64 data. Ensure it’s Base-64 encoded PEM, not DER. (On Windows, .CER files can be either; you may rename to .pem to avoid confusion. The file can actually have any extension, but .pem or .crt is standard.) If you have multiple internal CAs (a chain), you can concatenate them into one file – Node reads all certificates in that file.
136+
2. Make the PEM available on the build agent by placing it into a known path (e.g. C:\certs\CorpRootCA.pem or /etc/ssl/certs/CorpRootCA.pem).
137+
3. Set an OS environment variable NODE_EXTRA_CA_CERTS pointing to that PEM file. For example, on Windows, one can use PowerShell:
138+
```
139+
[Environment]::SetEnvironmentVariable("NODE_EXTRA_CA_CERTS", "C:\certs\CorpRootCA.pem", "Machine")
140+
```
122141
Learn more about [agent client certificate support](https://github.com/Microsoft/azure-pipelines-agent/blob/master/docs/design/clientcert.md).

0 commit comments

Comments
 (0)