---
title: Charmhub | Deploy MongoDB using Charmhub - The Open Operator Collection
description: Deploy the latest version of MongoDB on any cloud.
url: https://charmhub.io/mongodb/libraries/mongodb_tls
---

# MongoDB

[Canonical](https://charmhub.io/publisher/data-platform "View all packages from Canonical")

* [Canonical](https://charmhub.io/publisher/data-platform "View all packages from Canonical")
* [Databases](https://charmhub.io/?filter=databases)

Platform:

24.04

22.04

6/stable 265

```
juju deploy mongodb --channel 6/stable
```

[Learn to deploy on juju >](https://juju.is/docs/juju/manage-applications)

[Toggle side navigation](https://charmhub.io/mongodb/libraries/mongodb_tls#drawer)

## charms.mongodb.v1.mongodb\_tls

* [*Docstrings*Docstrings](https://charmhub.io/mongodb/libraries/mongodb_tls)
  [*Code*Source code](https://charmhub.io/mongodb/libraries/mongodb_tls/source-code)
* + Download

    Fetch library

    ```
    charmcraft fetch-lib charms.mongodb.v1.mongodb_tls
    ```

    [Download mongodb\_tls.py](https://charmhub.io/mongodb/libraries/mongodb_tls/download)
  + *Last updated* 09 Oct 2024
  + *Revision* Library version 1.5

In this class we manage client database relations.

This class creates user and database for each application relation
and expose needed information for client connection via fields in
external relation.

---

Index

* [class MongoDBTLS](https://charmhub.io/mongodb/libraries/mongodb_tls#mongodbtls)
* + [def \_\_init\_\_(
    self,
    charm,
    peer\_relation,
    substrate)](https://charmhub.io/mongodb/libraries/mongodb_tls#mongodbtls-__init__)
* + [def is\_tls\_enabled(
    self,
    internal)](https://charmhub.io/mongodb/libraries/mongodb_tls#mongodbtls-is_tls_enabled)
* + [def request\_certificate(
    self,
    param,
    internal)](https://charmhub.io/mongodb/libraries/mongodb_tls#mongodbtls-request_certificate)
* + [def is\_waiting\_for\_both\_certs(
    self)](https://charmhub.io/mongodb/libraries/mongodb_tls#mongodbtls-is_waiting_for_both_certs)
* + [def request\_new\_certificates(
    self,
    internal)](https://charmhub.io/mongodb/libraries/mongodb_tls#mongodbtls-request_new_certificates)
* + [def get\_new\_sans(
    self)](https://charmhub.io/mongodb/libraries/mongodb_tls#mongodbtls-get_new_sans)
* + [def get\_current\_sans(
    self,
    internal)](https://charmhub.io/mongodb/libraries/mongodb_tls#mongodbtls-get_current_sans)
* + [def get\_tls\_files(
    self,
    internal)](https://charmhub.io/mongodb/libraries/mongodb_tls#mongodbtls-get_tls_files)
* + [def set\_tls\_secret(
    self,
    internal,
    label\_name,
    contents)](https://charmhub.io/mongodb/libraries/mongodb_tls#mongodbtls-set_tls_secret)
* + [def get\_tls\_secret(
    self,
    internal,
    label\_name)](https://charmhub.io/mongodb/libraries/mongodb_tls#mongodbtls-get_tls_secret)
* + [def is\_set\_waiting\_for\_cert\_to\_update(
    self,
    internal)](https://charmhub.io/mongodb/libraries/mongodb_tls#mongodbtls-is_set_waiting_for_cert_to_update)
* + [def set\_waiting\_for\_cert\_to\_update(
    self,
    waiting,
    internal)](https://charmhub.io/mongodb/libraries/mongodb_tls#mongodbtls-set_waiting_for_cert_to_update)

#### class MongoDBTLS

Description

In this class we manage client database relations. None

Methods

MongoDBTLS.
\_\_init\_\_(

*self*

,
charm

,
peer\_relation

,
substrate
)

Description

Manager of MongoDB client relations. None

MongoDBTLS.
is\_tls\_enabled(

*self*

,
internal: bool
)

Description

Returns a boolean indicating if TLS for a given internal/external is enabled. None

MongoDBTLS.
request\_certificate(

*self*

,
param

,
internal: bool
)

Description

Request TLS certificate. None

MongoDBTLS.
is\_waiting\_for\_both\_certs(

*self*
)

Description

Returns a boolean indicating whether additional certs are needed. None

MongoDBTLS.
request\_new\_certificates(

*self*

,
internal: bool
)

Description

Requests the renewel of a new certificate. None

MongoDBTLS.
get\_new\_sans(

*self*
)

Create a list of DNS names for a MongoDB unit.

Returns

A list representing the hostnames of the MongoDB unit.

MongoDBTLS.
get\_current\_sans(

*self*

,
internal: bool
)

Description

Gets the current SANs for the unit cert. None

MongoDBTLS.
get\_tls\_files(

*self*

,
internal: bool
)

Prepare TLS files in special MongoDB way.

Description

MongoDB needs two files:
— CA file should have a full chain.
— PEM file should have private key and certificate without certificate chain.

MongoDBTLS.
set\_tls\_secret(

*self*

,
internal: bool

,
label\_name: str

,
contents: str
)

Description

Sets TLS secret, based on whether or not it is related to internal connections. None

MongoDBTLS.
get\_tls\_secret(

*self*

,
internal: bool

,
label\_name: str
)

Description

Gets TLS secret, based on whether or not it is related to internal connections. None

MongoDBTLS.
is\_set\_waiting\_for\_cert\_to\_update(

*self*

,
internal: bool
)

Description

Returns True if we are waiting for a cert to update. None

MongoDBTLS.
set\_waiting\_for\_cert\_to\_update(

*self*

,
waiting: bool

,
internal: bool
)

Description

Sets a boolean indicator, for whether or not we are waiting for a cert to update. None
