Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
slapos
Commits
7b3f3d01
Commit
7b3f3d01
authored
Nov 24, 2011
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clever way to generate random CommonName only once
parent
087b7f85
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
2 deletions
+6
-2
slapos/recipe/kvm/__init__.py
slapos/recipe/kvm/__init__.py
+6
-2
No files found.
slapos/recipe/kvm/__init__.py
View file @
7b3f3d01
...
@@ -34,6 +34,7 @@ import zc.buildout
...
@@ -34,6 +34,7 @@ import zc.buildout
import
pkg_resources
import
pkg_resources
import
ConfigParser
import
ConfigParser
import
hashlib
import
hashlib
import
uuid
class
Recipe
(
BaseSlapRecipe
):
class
Recipe
(
BaseSlapRecipe
):
...
@@ -321,13 +322,16 @@ class Recipe(BaseSlapRecipe):
...
@@ -321,13 +322,16 @@ class Recipe(BaseSlapRecipe):
certificate_authority_path
=
config
[
'ca_dir'
]
certificate_authority_path
=
config
[
'ca_dir'
]
)
)
def
requestCertificate
(
self
,
name
):
def
requestCertificateRandomName
(
self
,
name
):
"""Add certificate to be generated, using 'name + random number' as Common
Name. If certificate already exists, it won't be regenerated.
"""
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
=
ConfigParser
.
RawConfigParser
()
parser
.
add_section
(
'certificate'
)
parser
.
add_section
(
'certificate'
)
parser
.
set
(
'certificate'
,
'name'
,
name
)
parser
.
set
(
'certificate'
,
'name'
,
name
+
uuid
.
uuid1
()
)
parser
.
set
(
'certificate'
,
'key_file'
,
key
)
parser
.
set
(
'certificate'
,
'key_file'
,
key
)
parser
.
set
(
'certificate'
,
'certificate_file'
,
certificate
)
parser
.
set
(
'certificate'
,
'certificate_file'
,
certificate
)
parser
.
write
(
open
(
os
.
path
.
join
(
self
.
ca_request_dir
,
hash
),
'w'
))
parser
.
write
(
open
(
os
.
path
.
join
(
self
.
ca_request_dir
,
hash
),
'w'
))
...
...
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