# From Python to Rust

**URL:** <https://discuss.elastic.co/t/from-python-to-rust/344329>\
**Category:** Elasticsearch\
**Created:** [October 3, 2023, 4:21pm UTC](https://discuss.elastic.co/t/from-python-to-rust/344329 "2023-10-03T16:21:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![FrederickFrance](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/frederickfrance/32/126231_2.png) [@FrederickFrance](https://discuss.elastic.co/u/FrederickFrance)\
**Post date:** [October 3, 2023, 4:21pm UTC](https://discuss.elastic.co/t/from-python-to-rust/344329/1 "2023-10-03T16:21:40Z")

</div>

Hi all,

I'm a newbie with Python and Elasticsearch.  
I'm trying to create a client from host, username and password.

With Python, the original code is:

```python
Elasticsearch(
            hosts=hosts,
            http_auth=(es_username, es_password),
            use_ssl=True,
            verify_certs=False,
            ssl_show_warn=False,
            timeout=600,
        )

```

For the moment, I transform it to:

```rust
Elasticsearch::new(
            TransportBuilder::new(SingleNodeConnectionPool::new(Url::parse(&host)?))
                .timeout(Duration::from_secs(600))
                .auth(elasticsearch::auth::Credentials::Basic(u, p))
                .build()?,
        )

```

Even with the document, I'm unable to understand how to adapt `use_ssl=True, verify_certs=False, ssl_show_warn=False`.

Could someone help me ?

Regards

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [October 3, 2023, 4:43pm UTC](https://discuss.elastic.co/t/from-python-to-rust/344329/2 "2023-10-03T16:43:56Z")

</div>

I do not use Rust, but on the [documentation](https://docs.rs/elasticsearch/8.5.0-alpha.1/elasticsearch/cert/enum.CertificateValidation.html#no-validation), there is an example for when you do not want to verify the certificates.

It seems that you just need to add `.cert_validation(CertificateValidation::None)` to your _TransportBuilder_

Not sure if the other options, `use_ssl` and `ssl_show_warn` are needed or have equivalents.

---

<div class="post-metadata">

**Author:** ![FrederickFrance](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/frederickfrance/32/126231_2.png) [@FrederickFrance](https://discuss.elastic.co/u/FrederickFrance)\
**Post date:** [October 4, 2023, 7:34am UTC](https://discuss.elastic.co/t/from-python-to-rust/344329/3 "2023-10-04T07:34:56Z")

</div>

Thanks  
I'm stupid, I used **elasticsearch = { version = "7.17.7-alpha.1", default-features = false }**  
It's why I didn't success to use **cert\_validation**.  
Now, I'm looking for ssl.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 1, 2023, 7:35am UTC](https://discuss.elastic.co/t/from-python-to-rust/344329/4 "2023-11-01T07:35:41Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
