-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from NBISweden/TLS
Add TLS capabilities
- Loading branch information
Showing
9 changed files
with
104 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,4 +49,7 @@ | |
org_welcome_url = 'https://ega-archive.org/' | ||
org_contact_url = 'mailto:[email protected]' | ||
org_logo_url = 'https://legacy.ega-archive.org/images/logo.png' | ||
org_info = '' | ||
org_info = '' | ||
|
||
beacon_server_crt = '' | ||
beacon_server_key = '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,19 @@ | ||
from pymongo.mongo_client import MongoClient | ||
from beacon.connections.mongo import conf | ||
import os | ||
|
||
client = MongoClient("mongodb://{}:{}@{}:{}/{}?authSource={}".format( | ||
uri = "mongodb://{}:{}@{}:{}/{}?authSource={}".format( | ||
conf.database_user, | ||
conf.database_password, | ||
conf.database_host, | ||
conf.database_port, | ||
conf.database_name, | ||
conf.database_auth_source | ||
)) | ||
) | ||
|
||
if os.path.isfile(conf.database_certificate): | ||
uri += '&tls=true&tlsCertificateKeyFile={}'.format(conf.database_certificate) | ||
if os.path.isfile(conf.database_cafile): | ||
uri += '&tlsCAFile={}'.format(conf.database_cafile) | ||
|
||
client = MongoClient(uri) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from pymongo.mongo_client import MongoClient | ||
from pymongo.errors import ConnectionFailure | ||
import conf | ||
import os | ||
|
||
|
||
uri = "mongodb://{}:{}@{}:{}/{}?authSource={}".format( | ||
conf.database_user, | ||
conf.database_password, | ||
conf.database_host, | ||
conf.database_port, | ||
conf.database_name, | ||
conf.database_auth_source | ||
) | ||
|
||
if os.path.isfile(conf.database_certificate): | ||
uri += '&tls=true&tlsCertificateKeyFile={}'.format(conf.database_certificate) | ||
if os.path.isfile(conf.database_cafile): | ||
uri += '&tlsCAFile={}'.format(conf.database_cafile) | ||
|
||
client = MongoClient(uri, serverSelectionTimeoutMS=30000) | ||
try: | ||
client.admin.command('ping') | ||
except ConnectionFailure as err: | ||
print(f"Database error encountered: {err}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters