Skip to content

Commit cea096c

Browse files
committed
Regenerate docs
1 parent 20186ed commit cea096c

File tree

6 files changed

+37
-95
lines changed

6 files changed

+37
-95
lines changed

docs/client-concepts/certificates/working-with-certificates.asciidoc

Lines changed: 10 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@ please modify the original csharp file found at the link and submit the PR with
1515
[[working-with-certificates]]
1616
=== Working with certificates
1717

18-
If you've enabled SSL on Elasticsearch with https://www.elastic.co/products/x-pack[X-Pack] or through a
18+
If you've enabled SSL on Elasticsearch with https://www.elastic.co/products/elastic-stack[Elastic Stack Security features], or through a
1919
proxy in front of Elasticsearch, and the Certificate Authority (CA)
20-
that generated the certificate is trusted by the machine running the client code, there should be nothing you'll have to do to talk
20+
that generated the certificate is trusted by the machine running the client code, there should be nothing for you to do to talk
2121
to the cluster over HTTPS with the client.
2222

23-
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,
24-
you can pre-empt this though a custom validation callback on the global static
23+
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.
24+
With .NET Framework, you can pre-empt this though a custom validation callback on the global static
2525
`ServicePointManager.ServerCertificateValidationCallback`. Most examples you will find doing this this will simply return `true` from the
2626
validation callback and merrily whistle off into the sunset. **This is not advisable** as it allows *any* HTTPS traffic through in the
2727
current `AppDomain` *without* any validation. Here's a concrete example:
2828

29-
Imagine you deploy a web application that talks to Elasticsearch over HTTPS through NEST, and also uses some third party SOAP/WSDL endpoint;
30-
by setting
29+
Imagine you deploy a web application that talks to Elasticsearch over HTTPS using NEST, and also uses some third party SOAP/WSDL endpoint.
30+
By setting the following
3131

3232
[source,csharp]
3333
----
@@ -61,7 +61,7 @@ public class DenyAllCertificatesCluster : SslAndKpiXPackCluster
6161
.ServerCertificateValidationCallback(CertificateValidations.DenyAll); <1>
6262
}
6363
----
64-
<1> synonymous with the previous lambda expression
64+
<1> use a lambda expression or `CertificateValidations.DenyAll` to deny all validation
6565

6666
===== Allowing all certificate validation
6767

@@ -72,18 +72,18 @@ Here we set up `ConnectionSettings` with a validation callback that allows all c
7272
public class AllowAllCertificatesCluster : SslAndKpiXPackCluster
7373
{
7474
protected override ConnectionSettings ConnectionSettings(ConnectionSettings s) => s
75-
.ServerCertificateValidationCallback((o, certificate, chain, errors) => true)
75+
.ServerCertificateValidationCallback((o, certificate, chain, errors) => true) <1>
7676
.ServerCertificateValidationCallback(CertificateValidations.AllowAll); <1>
7777
}
7878
----
79-
<1> synonymous with the previous lambda expression
79+
<1> use a lambda expression or `CertificateValidations.AllowAll` to allow all validation
8080

8181
===== Allowing certificates from a Certificate Authority
8282

8383
If your client application has access to the public CA certificate locally, Elasticsearch.NET and NEST ship with some handy helpers
8484
that can assert that a certificate the server presents is one that came from the local CA.
8585

86-
If you use X-Pack's {ref_current}/certutil.html[`elasticsearch-certutil` tool] to generate SSL certificates, the generated node certificate
86+
If you use {ref_current}/certutil.html[`elasticsearch-certutil` tool] to generate SSL certificates, the generated node certificate
8787
does not include the CA in the certificate chain, in order to cut down on SSL handshake size. In those case you can use
8888
`CertificateValidations.AuthorityIsRoot` and pass it your local copy of the CA public key to assert that
8989
the certificate the server presented was generated using it
@@ -120,60 +120,3 @@ If you go for a vendor generated SSL certificate, it's common practice for the c
120120
in the certificate chain. When using such a certificate, use `CertificateValidations.AuthorityPartOfChain` which validates that
121121
the local CA certificate is part of the chain that was used to generate the servers key.
122122

123-
==== Client Certificates
124-
125-
X-Pack also allows you to configure a {ref_current}/configuring-pki-realm.html[PKI realm] to enable user authentication
126-
through client certificates. The {ref_current}/certutil.html[`elasticsearch-certutil` tool] included with X-Pack allows you to
127-
generate client certificates as well and assign the distinguished name (DN) of the
128-
certificate to a user with a certain role.
129-
130-
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
131-
as one certificate. The easiest way to do this is to generate a `pfx` or `p12` file from the `.cer` and `.key`
132-
and attach these to requests using `new X509Certificate(pathToPfx)`.
133-
134-
You can pass a client certificate on `ConnectionSettings` for *all* requests.
135-
136-
[source,csharp]
137-
----
138-
public class PkiCluster : CertgenCaCluster
139-
{
140-
public PkiCluster() : base(new SslAndKpiClusterConfiguration
141-
{
142-
DefaultNodeSettings =
143-
{
144-
{"xpack.security.authc.realms.file1.enabled", "false"},
145-
{"xpack.security.http.ssl.client_authentication", "required"}
146-
}
147-
}) { }
148-
149-
protected override ConnectionSettings Authenticate(ConnectionSettings s) => s <1>
150-
.ClientCertificate(new X509Certificate2(this.ClusterConfiguration.FileSystem.ClientCertificate));
151-
}
152-
----
153-
<1> Set the client certificate on `ConnectionSettings`
154-
155-
Or on a per request basis on `RequestConfiguration` which will take precedence over the ones defined on `ConnectionConfiguration`
156-
157-
==== Object Initializer syntax example
158-
159-
[source,csharp]
160-
----
161-
new RootNodeInfoRequest
162-
{
163-
RequestConfiguration = new RequestConfiguration
164-
{
165-
ClientCertificates = new X509Certificate2Collection { new X509Certificate2(this.Certificate) }
166-
}
167-
}
168-
----
169-
170-
==== Fluent DSL example
171-
172-
[source,csharp]
173-
----
174-
s => s
175-
.RequestConfiguration(r => r
176-
.ClientCertificate(this.Certificate)
177-
)
178-
----
179-

docs/client-concepts/connection-pooling/exceptions/unexpected-exceptions.asciidoc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,11 @@ Finally, we assert that we can still see the audit trail for the whole coordinat
7777
----
7878
var audit = new Auditor(() => VirtualClusterWith
7979
.Nodes(10)
80+
#if DOTNETCORE
8081
.ClientCalls(r => r.OnPort(9200).FailAlways(new System.Net.Http.HttpRequestException("recover"))) <1>
82+
#else
83+
.ClientCalls(r => r.OnPort(9200).FailAlways(new System.Net.WebException("recover"))) <1>
84+
#endif
8185
.ClientCalls(r => r.OnPort(9201).FailAlways(new Exception("boom!"))) <2>
8286
.StaticConnectionPool()
8387
.Settings(s => s.DisablePing())
@@ -96,7 +100,7 @@ audit = await audit.TraceUnexpectedException(
96100
}
97101
);
98102
----
99-
<1> calls on 9200 set up to throw a `HttpRequestException`
103+
<1> calls on 9200 set up to throw a `HttpRequestException` or a `WebException`
100104

101105
<2> calls on 9201 set up to throw an `Exception`
102106

docs/client-concepts/connection-pooling/exceptions/unrecoverable-exceptions.asciidoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,13 @@ var audit = new Auditor(() => VirtualClusterWith
121121
.Ping(r => r.SucceedAlways())
122122
.ClientCalls(r => r.FailAlways(401).ReturnByteResponse(HtmlNginx401Response, "application/json")) <1>
123123
.StaticConnectionPool()
124-
.Settings(s=>s.SkipDeserializationForStatusCodes(401))
124+
.Settings(s => s.SkipDeserializationForStatusCodes(401))
125125
);
126126
127127
audit = await audit.TraceElasticsearchException(
128128
new ClientCall {
129129
{ AuditEvent.PingSuccess, 9200 },
130-
{ AuditEvent.BadResponse, 9200 },
130+
{ AuditEvent.BadResponse, 9201 },
131131
},
132132
(e) =>
133133
{

docs/client-concepts/connection/modifying-default-connection.asciidoc

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -97,42 +97,30 @@ to the request, change the maximum number of connections allowed to an endpoint,
9797
By deriving from `HttpConnection`, it is possible to change the behaviour of the connection. The following
9898
provides some examples
9999

100-
On .NET full framework the overrides on HttpConnection are different as they are geared towards using HttpWebRequest.
101-
Here are two examples for .NET full framework
102-
103100
[source,csharp]
104101
----
105102
public class MyCustomHttpConnection : HttpConnection
106103
{
107-
protected override void AlterServicePoint(ServicePoint requestServicePoint, RequestData requestData)
104+
protected override HttpRequestMessage CreateRequestMessage(RequestData requestData)
108105
{
109-
base.AlterServicePoint(requestServicePoint, requestData);
110-
requestServicePoint.ConnectionLimit = 10000;
111-
requestServicePoint.UseNagleAlgorithm = true;
106+
var message = base.CreateRequestMessage(requestData);
107+
var header = string.Empty;
108+
message.Headers.Authorization = new AuthenticationHeaderValue("Negotiate", header);
109+
return message;
112110
}
113111
}
114112
115-
public class X509CertificateHttpConnection : HttpConnection
113+
public class KerberosConnection : HttpConnection
116114
{
117-
protected override HttpWebRequest CreateHttpWebRequest(RequestData requestData)
115+
protected override HttpRequestMessage CreateRequestMessage(RequestData requestData)
118116
{
119-
var request = base.CreateHttpWebRequest(requestData);
120-
request.ClientCertificates.Add(new X509Certificate("file_path_to_cert"));
121-
return request;
117+
var message = base.CreateRequestMessage(requestData);
118+
var header = string.Empty;
119+
message.Headers.Authorization = new AuthenticationHeaderValue("Negotiate", header);
120+
return message;
122121
}
123122
}
124123
----
125124

126-
As before, a new instance of the custom connection is passed to `ConnectionSettings` in order to
127-
use
128-
129-
[source,csharp]
130-
----
131-
var connection = new X509CertificateHttpConnection();
132-
var connectionPool = new SingleNodeConnectionPool(new Uri("http://localhost:9200"));
133-
var settings = new ConnectionSettings(connectionPool, connection);
134-
var client = new ElasticClient(settings);
135-
----
136-
137125
See <<working-with-certificates, Working with certificates>> for further details.
138126

docs/client-concepts/high-level/mapping/ignoring-properties.asciidoc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ please modify the original csharp file found at the link and submit the PR with
1717

1818
Properties on a POCO can be ignored for mapping purposes in a few ways:
1919

20-
* Using the `Ignore` property on a derived `ElasticsearchPropertyAttribute` type applied to
20+
* Using the `Ignore` property on a derived `ElasticsearchPropertyAttributeBase` type, such as `TextAttribute`, applied to
2121
the property that should be ignored on the POCO
2222

23+
* Using the `Ignore` property on `PropertyNameAttribute` applied to a property that should be ignored on the POCO
24+
2325
* Using the `.DefaultMappingFor<TDocument>(Func<ClrTypeMappingDescriptor<TDocument>, IClrTypeMapping<TDocument>>
2426
selector)` on `ConnectionSettings`
2527

@@ -42,8 +44,11 @@ public class CompanyWithAttributesAndPropertiesToIgnore
4244
[Text(Ignore = true)]
4345
public string PropertyToIgnore { get; set; }
4446
47+
[PropertyName("anotherPropertyToIgnore", Ignore = true)]
4548
public string AnotherPropertyToIgnore { get; set; }
4649
50+
public string FluentMappingPropertyToIgnore { get; set; }
51+
4752
[Ignore, JsonIgnore]
4853
public string JsonIgnoredProperty { get; set; }
4954
}
@@ -56,7 +61,7 @@ All of the properties except `Name` have been ignored in the mapping
5661
var connectionSettings = new ConnectionSettings(new InMemoryConnection()) <1>
5762
.DisableDirectStreaming() <2>
5863
.DefaultMappingFor<CompanyWithAttributesAndPropertiesToIgnore>(m => m
59-
.Ignore(p => p.AnotherPropertyToIgnore)
64+
.Ignore(p => p.FluentMappingPropertyToIgnore)
6065
);
6166
6267
var client = new ElasticClient(connectionSettings);

docs/code-standards/naming-conventions.asciidoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ var elasticsearchNetAssembly = typeof(IElasticLowLevelClient).Assembly;
173173
174174
var exceptions = new List<Type>
175175
{
176+
elasticsearchNetAssembly.GetType("Microsoft.CodeAnalysis.EmbeddedAttribute"),
177+
elasticsearchNetAssembly.GetType("System.Runtime.CompilerServices.IsReadOnlyAttribute"),
176178
elasticsearchNetAssembly.GetType("System.AssemblyVersionInformation"),
177179
elasticsearchNetAssembly.GetType("System.FormattableString"),
178180
elasticsearchNetAssembly.GetType("System.Runtime.CompilerServices.FormattableStringFactory"),

0 commit comments

Comments
 (0)