Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Roque
slapos
Commits
8135944a
Commit
8135944a
authored
Jun 10, 2013
by
Cédric Le Ninivin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
certificate-authority: Add ugly hack to ca request to use custom certificates instead
parent
37d067b6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
13 deletions
+27
-13
slapos/recipe/certificate_authority/__init__.py
slapos/recipe/certificate_authority/__init__.py
+27
-13
No files found.
slapos/recipe/certificate_authority/__init__.py
View file @
8135944a
...
@@ -103,16 +103,27 @@ class Request(Recipe):
...
@@ -103,16 +103,27 @@ class Request(Recipe):
key_file
=
self
.
options
[
'key-file'
]
key_file
=
self
.
options
[
'key-file'
]
cert_file
=
self
.
options
[
'cert-file'
]
cert_file
=
self
.
options
[
'cert-file'
]
key_content
=
self
.
options
.
get
(
'key-content'
,
None
)
cert_content
=
self
.
options
.
get
(
'cert-content'
,
None
)
request_needed
=
True
name
=
self
.
options
[
'name'
]
name
=
self
.
options
[
'name'
]
hash_
=
hashlib
.
sha512
(
name
).
hexdigest
()
hash_
=
hashlib
.
sha512
(
name
).
hexdigest
()
key
=
os
.
path
.
join
(
self
.
ca_private
,
hash_
+
self
.
ca_key_ext
)
key
=
os
.
path
.
join
(
self
.
ca_private
,
hash_
+
self
.
ca_key_ext
)
certificate
=
os
.
path
.
join
(
self
.
ca_certs
,
hash_
+
self
.
ca_crt_ext
)
certificate
=
os
.
path
.
join
(
self
.
ca_certs
,
hash_
+
self
.
ca_crt_ext
)
parser
=
ConfigParser
.
RawConfigParser
()
parser
.
add_section
(
'certificate'
)
# XXX Ugly hack to quickly provide custom certificate/key to everyone using the recipe
parser
.
set
(
'certificate'
,
'name'
,
name
)
if
key_content
and
cert_content
:
parser
.
set
(
'certificate'
,
'key_file'
,
key
)
open
(
key
,
'w'
).
write
(
key_content
)
parser
.
set
(
'certificate'
,
'certificate_file'
,
certificate
)
open
(
certificate
,
'w'
).
write
(
cert_content
)
parser
.
write
(
open
(
os
.
path
.
join
(
self
.
request_directory
,
hash_
),
'w'
))
request_needed
=
False
else
:
parser
=
ConfigParser
.
RawConfigParser
()
parser
.
add_section
(
'certificate'
)
parser
.
set
(
'certificate'
,
'name'
,
name
)
parser
.
set
(
'certificate'
,
'key_file'
,
key
)
parser
.
set
(
'certificate'
,
'certificate_file'
,
certificate
)
parser
.
write
(
open
(
os
.
path
.
join
(
self
.
request_directory
,
hash_
),
'w'
))
for
link
in
[
key_file
,
cert_file
]:
for
link
in
[
key_file
,
cert_file
]:
if
os
.
path
.
islink
(
link
):
if
os
.
path
.
islink
(
link
):
...
@@ -123,11 +134,14 @@ class Request(Recipe):
...
@@ -123,11 +134,14 @@ class Request(Recipe):
os
.
symlink
(
key
,
key_file
)
os
.
symlink
(
key
,
key_file
)
os
.
symlink
(
certificate
,
cert_file
)
os
.
symlink
(
certificate
,
cert_file
)
wrapper
=
self
.
createPythonScript
(
path_list
=
[
key_file
,
cert_file
]
self
.
options
[
'wrapper'
],
if
request_needed
:
'slapos.recipe.librecipe.execute.execute_wait'
,
wrapper
=
self
.
createPythonScript
(
[
[
self
.
options
[
'executable'
]],
self
.
options
[
'wrapper'
],
[
certificate
,
key
]
],
'slapos.recipe.librecipe.execute.execute_wait'
,
)
[
[
self
.
options
[
'executable'
]],
[
certificate
,
key
]
],
)
path_list
.
append
(
wrapper
)
return
[
key_file
,
cert_file
,
wrapper
]
return
path_list
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