Skip to content

Commit 20186ed

Browse files
committed
Update Working with certificates docs
1 parent 0474674 commit 20186ed

File tree

1 file changed

+16
-19
lines changed

1 file changed

+16
-19
lines changed

src/Tests/Tests/ClientConcepts/Certificates/WorkingWithCertificates.doc.cs

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,25 @@ namespace Tests.ClientConcepts.Certificates
1717
{
1818
/**=== Working with certificates
1919
*
20-
* If you've enabled SSL on Elasticsearch with https://www.elastic.co/products/x-pack[X-Pack] or through a
20+
* If you've enabled SSL on Elasticsearch with https://www.elastic.co/products/elastic-stack[Elastic Stack Security features], or through a
2121
* proxy in front of Elasticsearch, and the Certificate Authority (CA)
22-
* that generated the certificate is trusted by the machine running the client code, there should be nothing you'll have to do to talk
22+
* that generated the certificate is trusted by the machine running the client code, there should be nothing for you to do to talk
2323
* to the cluster over HTTPS with the client.
2424
*
25-
* If you are using your own CA which is not trusted however, .NET won't allow you to make HTTPS calls to that endpoint by default. With .NET,
26-
* you can pre-empt this though a custom validation callback on the global static
25+
* If you are using your own CA which is not trusted however, .NET won't allow you to make HTTPS calls to that endpoint by default.
26+
* With .NET Framework, you can pre-empt this though a custom validation callback on the global static
2727
* `ServicePointManager.ServerCertificateValidationCallback`. Most examples you will find doing this this will simply return `true` from the
2828
* validation callback and merrily whistle off into the sunset. **This is not advisable** as it allows *any* HTTPS traffic through in the
2929
* current `AppDomain` *without* any validation. Here's a concrete example:
3030
*
3131
*/
3232
public class WorkingWithCertificates
3333
{
34-
/** Imagine you deploy a web application that talks to Elasticsearch over HTTPS through NEST, and also uses some third party SOAP/WSDL endpoint;
35-
* by setting
34+
/** Imagine you deploy a web application that talks to Elasticsearch over HTTPS using NEST, and also uses some third party SOAP/WSDL endpoint.
35+
* By setting the following
3636
*/
37-
#if !DOTNETCORE
3837
public void ServerValidationCallback() => ServicePointManager.ServerCertificateValidationCallback +=
3938
(sender, cert, chain, errors) => true;
40-
#endif
4139
/**
4240
* validation will not be performed for HTTPS connections to *both* Elasticsearch *and* that external web service.
4341
*
@@ -60,7 +58,7 @@ public class DenyAllCertificatesCluster : SslAndKpiXPackCluster
6058
{
6159
protected override ConnectionSettings ConnectionSettings(ConnectionSettings s) => s
6260
.ServerCertificateValidationCallback((o, certificate, chain, errors) => false)
63-
.ServerCertificateValidationCallback(CertificateValidations.DenyAll); // <1> synonymous with the previous lambda expression
61+
.ServerCertificateValidationCallback(CertificateValidations.DenyAll); // <1> use a lambda expression or `CertificateValidations.DenyAll` to deny all validation
6462
}
6563

6664
//hide
@@ -87,8 +85,8 @@ protected override void AssertHttpRequestException(HttpRequestException e)
8785
public class AllowAllCertificatesCluster : SslAndKpiXPackCluster
8886
{
8987
protected override ConnectionSettings ConnectionSettings(ConnectionSettings s) => s
90-
.ServerCertificateValidationCallback((o, certificate, chain, errors) => true)
91-
.ServerCertificateValidationCallback(CertificateValidations.AllowAll); // <1> synonymous with the previous lambda expression
88+
.ServerCertificateValidationCallback((o, certificate, chain, errors) => true) // <1>
89+
.ServerCertificateValidationCallback(CertificateValidations.AllowAll); // <1> use a lambda expression or `CertificateValidations.AllowAll` to allow all validation
9290
}
9391
/**
9492
* This is not recommended in production.
@@ -111,7 +109,7 @@ public AllowAllSslCertificatesApiTests(AllowAllCertificatesCluster cluster, Endp
111109
* If your client application has access to the public CA certificate locally, Elasticsearch.NET and NEST ship with some handy helpers
112110
* that can assert that a certificate the server presents is one that came from the local CA.
113111
*
114-
* If you use X-Pack's {ref_current}/certutil.html[+elasticsearch-certutil+ tool] to generate SSL certificates, the generated node certificate
112+
* If you use {ref_current}/certutil.html[+elasticsearch-certutil+ tool] to generate SSL certificates, the generated node certificate
115113
* does not include the CA in the certificate chain, in order to cut down on SSL handshake size. In those case you can use
116114
* `CertificateValidations.AuthorityIsRoot` and pass it your local copy of the CA public key to assert that
117115
* the certificate the server presented was generated using it
@@ -179,14 +177,13 @@ protected override void AssertHttpRequestException(HttpRequestException e)
179177
/**
180178
* ==== Client Certificates
181179
*
182-
* X-Pack also allows you to configure a {ref_current}/configuring-pki-realm.html[PKI realm] to enable user authentication
183-
* through client certificates. The {ref_current}/certutil.html[+elasticsearch-certutil+ tool] included with X-Pack allows you to
184-
* generate client certificates as well and assign the distinguished name (DN) of the
185-
* certificate to a user with a certain role.
180+
* Elastic Stack Security features allow you to configure a {ref_current}/configuring-pki-realm.html[PKI realm] to enable user authentication
181+
* through client certificates. The {ref_current}/certutil.html[+elasticsearch-certutil+ tool] included with the default distribution
182+
* allows you to generate client certificates as well and assign the distinguished name (DN) of the certificate to a user with a certain role.
186183
*
187-
* By default, the `elasticsearch-certutil` tool only generates a public certificate (`.cer`) and a private key `.key`. To authenticate with client certificates, you need to present both
188-
* as one certificate. The easiest way to do this is to generate a `pfx` or `p12` file from the `.cer` and `.key`
189-
* and attach these to requests using `new X509Certificate(pathToPfx)`.
184+
* By default, the `elasticsearch-certutil` tool only generates a public certificate (`.cer`) and a private key `.key`.
185+
* To authenticate with client certificates, you need to present both as one certificate. The easiest way to do this is to generate a `pfx`
186+
* or `p12` file from the `.cer` and `.key` and attach these to requests using `new X509Certificate(pathToPfx)`.
190187
*
191188
* You can pass a client certificate on `ConnectionSettings` for *all* requests.
192189
*

0 commit comments

Comments
 (0)