You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/pipelines/agents/certificate.md
+42-23Lines changed: 42 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,10 @@
1
1
---
2
2
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
4
4
ms.topic: conceptual
5
5
ms.assetid: 09E36E4D-D94B-4F5B-BE4D-9E7B4E7B68E2
6
6
ms.reviewer: chrispat
7
-
ms.date: 06/22/2023
7
+
ms.date: 08/05/2025
8
8
monikerRange: '< azure-devops'
9
9
---
10
10
@@ -14,9 +14,6 @@ monikerRange: '< azure-devops'
14
14
15
15
This topic explains how to run a self-hosted agent with a self-signed certificate.
16
16
17
-
> [!NOTE]
18
-
> This article applies to agent versions 2.x and newer.
19
-
20
17
## Work with SSL server certificate
21
18
22
19
```
@@ -31,15 +28,15 @@ Agent diagnostic log shows:
31
28
[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
32
29
```
33
30
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.
35
32
```
36
33
Windows: Windows certificate store
37
34
Linux: OpenSSL certificate store
38
35
macOS: OpenSSL certificate store for agent version 2.124.0 or below
39
36
Keychain for agent version 2.125.0 or above
40
37
```
41
38
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.
43
40
You should be good as long as SSL handshake finished correctly even you get a 401 for the request.
@@ -53,7 +50,7 @@ The agent version 2.125.0 or above has the ability to ignore SSL server certific
53
50
54
51
> [!IMPORTANT]
55
52
>
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.
57
54
58
55
Pass `--sslskipcertvalidation` during agent configuration
59
56
```
@@ -62,22 +59,23 @@ Pass `--sslskipcertvalidation` during agent configuration
62
59
63
60
> [!NOTE]
64
61
>
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)
67
64
68
65
### Git get sources fails with SSL certificate problem (Windows agent only)
66
+
69
67
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.
73
71
74
72
1. Set the following git config in global level by the agent's run as user.
> 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.
81
79
82
80
2. Enable git to use `SChannel` during configure with 2.129.0 or higher version agent
83
81
Pass `--gituseschannel` during agent configuration
@@ -86,20 +84,20 @@ There are 2 approaches to solve the problem.
86
84
```
87
85
> [!NOTE]
88
86
>
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`.
91
89
92
90
## Work with SSL client certificate
93
91
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.
95
93
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.
97
95
98
96
- 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)
103
101
- Use `SAME` password to protect Client certificate private key and Client certificate archive package, since they both have client certificate's private key
104
102
105
103
- 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
118
116
macOS: macOS Keychain
119
117
Windows: Windows Credential Store
120
118
```
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:
0 commit comments