-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add root_certificates option for ydb.DriverConfig (#525)
* Add root_certificates option for ydb.DriverConfig in example --------- Co-authored-by: Oleg Ovcharuk <[email protected]>
- Loading branch information
1 parent
10284db
commit aef5f66
Showing
2 changed files
with
29 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
# -*- coding: utf-8 -*- | ||
import os | ||
from typing import Optional | ||
|
||
|
||
def read_bytes(f): | ||
with open(f, "rb") as fr: | ||
return fr.read() | ||
|
||
|
||
def load_ydb_root_certificate(): | ||
path = os.getenv("YDB_SSL_ROOT_CERTIFICATES_FILE", None) | ||
def load_ydb_root_certificate(path: Optional[str] = None): | ||
path = path if path is not None else os.getenv("YDB_SSL_ROOT_CERTIFICATES_FILE", None) | ||
if path is not None and os.path.exists(path): | ||
return read_bytes(path) | ||
return None |