Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
J
Jupyter Docker Stacks
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
Jupyter Docker Stacks
Commits
735c5204
Commit
735c5204
authored
Sep 15, 2015
by
Peter Parente
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #35 from jtyberg/pem_dir
Ensure PEM file directory exists before creating file.
parents
78df4dc0
163867cb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
0 deletions
+12
-0
minimal-notebook/jupyter_notebook_config.py
minimal-notebook/jupyter_notebook_config.py
+12
-0
No files found.
minimal-notebook/jupyter_notebook_config.py
View file @
735c5204
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
from
jupyter_core.paths
import
jupyter_data_dir
from
jupyter_core.paths
import
jupyter_data_dir
import
subprocess
import
subprocess
import
os
import
os
import
errno
import
stat
PEM_FILE
=
os
.
path
.
join
(
jupyter_data_dir
(),
'notebook.pem'
)
PEM_FILE
=
os
.
path
.
join
(
jupyter_data_dir
(),
'notebook.pem'
)
...
@@ -13,11 +15,21 @@ c.NotebookApp.open_browser = False
...
@@ -13,11 +15,21 @@ c.NotebookApp.open_browser = False
# Set a certificate if USE_HTTPS is set to any value
# Set a certificate if USE_HTTPS is set to any value
if
'USE_HTTPS'
in
os
.
environ
:
if
'USE_HTTPS'
in
os
.
environ
:
if
not
os
.
path
.
isfile
(
PEM_FILE
):
if
not
os
.
path
.
isfile
(
PEM_FILE
):
# Ensure PEM_FILE directory exists
dir_name
=
os
.
path
.
dirname
(
PEM_FILE
)
try
:
os
.
makedirs
(
dir_name
)
except
OSError
as
exc
:
# Python >2.5
if
exc
.
errno
==
errno
.
EEXIST
and
os
.
path
.
isdir
(
dir_name
):
pass
else
:
raise
# Generate a certificate if one doesn't exist on disk
# Generate a certificate if one doesn't exist on disk
subprocess
.
check_call
([
'openssl'
,
'req'
,
'-new'
,
subprocess
.
check_call
([
'openssl'
,
'req'
,
'-new'
,
'-newkey'
,
'rsa:2048'
,
'-days'
,
'365'
,
'-nodes'
,
'-x509'
,
'-newkey'
,
'rsa:2048'
,
'-days'
,
'365'
,
'-nodes'
,
'-x509'
,
'-subj'
,
'/C=XX/ST=XX/L=XX/O=generated/CN=generated'
,
'-subj'
,
'/C=XX/ST=XX/L=XX/O=generated/CN=generated'
,
'-keyout'
,
PEM_FILE
,
'-out'
,
PEM_FILE
])
'-keyout'
,
PEM_FILE
,
'-out'
,
PEM_FILE
])
# Restrict access to PEM_FILE
os
.
chmod
(
PEM_FILE
,
stat
.
S_IRUSR
|
stat
.
S_IWUSR
)
c
.
NotebookApp
.
certfile
=
PEM_FILE
c
.
NotebookApp
.
certfile
=
PEM_FILE
# Set a password if PASSWORD is set
# Set a password if PASSWORD is set
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment