Skip to content

Commit

Permalink
implement and test the new CA store
Browse files Browse the repository at this point in the history
  • Loading branch information
mmomtchev committed Jan 28, 2025
1 parent dc504f2 commit 4dd6adf
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
10 changes: 10 additions & 0 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@
['builtin_python == "true" and OS == "linux"', {
'targets': [{
'target_name': 'builtin_python',
'direct_dependent_settings': {
'defines': [
'CACERT_FILE="/cacert.pem"',
]
},
'type': 'none',
'actions': [{
'action_name': 'Python',
Expand All @@ -128,6 +133,11 @@
'targets': [
{
'target_name': 'builtin_python',
'direct_dependent_settings': {
'defines': [
'CACERT_FILE="/cacert.pem"',
]
},
'type': 'none',
'actions': [{
'action_name': 'Python',
Expand Down
4 changes: 4 additions & 0 deletions src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ static Napi::Object PympInit(Env env, Object exports) {
memcpy(python_home, wstr.c_str(), wstr.size() * sizeof(wchar_t));
python_home[wstr.size()] = 0;
config.home = python_home;
#ifdef CACERT_FILE
auto cacert = std::string{pathPymport} + CACERT_FILE;
setenv("SSL_CERT_FILE", cacert.c_str(), 0);
#endif
}
#endif
auto status = Py_InitializeFromConfig(&config);
Expand Down
6 changes: 6 additions & 0 deletions test/pymport.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,4 +344,10 @@ describe('pymport', () => {
});

});

it('SSL module', () => {
const request = pymport('urllib.request');
const contents = request.get('urlopen').call('https://www.github.com').get('read').call();
assert.strictEqual(contents.type, 'bytes');
});
});
2 changes: 1 addition & 1 deletion wiki
Submodule wiki updated from 194840 to 812c37

0 comments on commit 4dd6adf

Please sign in to comment.