Skip to content

Commit e744578

Browse files
committed
updating the docs some more examples
1 parent 190e4fd commit e744578

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

README

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,22 @@ Simple use-case::
8888

8989
.. _Full documentation: https://elasticsearch-py.readthedocs.io/
9090

91+
Elastic Cloud (and SSL) use-case::
92+
93+
>>> from elasticsearch import Elasticsearch
94+
>>> es = Elasticsearch("https://elasticsearch.url:port", http_auth=('elastic','yourpassword'))
95+
>>> es.info()
96+
97+
Using SSL Context with a self-signed cert use-case::
98+
99+
>>> from elasticsearch import Elasticsearch
100+
>>> from elasticsearch.connection.http_urllib3 import create_ssl_context
101+
102+
>>> context = create_ssl_context(cafile="path/to/cafile.pem")
103+
>>> es = Elasticsearch("https://elasticsearch.url:port", ssl_context=context, http_auth=('elastic','yourpassword'))
104+
>>> es.info()
105+
106+
91107

92108
Features
93109
--------

docs/connection.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@ If you want to create your own `SSLContext` object you can create one natively u
5454
python SSL library with the `create_default_context` (https://docs.python.org/3/library/ssl.html#ssl.create_default_context) method
5555
or you can use the wrapper function :function:`~elasticsearch.connection.http_urllib3.create_ssl_context`.
5656

57+
To create an `SSLContext` object you only need to use one of cafile, capath or cadata::
58+
59+
>>> from elasticsearch.connection.http_urllib3 import create_ssl_context
60+
>>> context = create_ssl_context(cafile=None, capath=None, cadata=None)
61+
62+
* `cafile` is the path to your CA File
63+
* `capath` is the directory of a collection of CA's
64+
* `cadata` is either an ASCII string of one or more PEM-encoded certificates or a bytes-like object of DER-encoded certificates.
5765

5866
.. autoclass:: Urllib3HttpConnection
5967
:members:

0 commit comments

Comments
 (0)