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
Jean-Paul Smets
slapos
Commits
38e1bb4b
Commit
38e1bb4b
authored
Jun 06, 2011
by
Cédric de Saint Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MYSQL : Request certificate during recipe
parent
4911ab8f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
2 deletions
+18
-2
slapos/recipe/mysql/__init__.py
slapos/recipe/mysql/__init__.py
+18
-2
No files found.
slapos/recipe/mysql/__init__.py
View file @
38e1bb4b
...
...
@@ -25,10 +25,12 @@
#
##############################################################################
from
slapos.recipe.librecipe
import
BaseSlapRecipe
import
hashlib
import
os
import
pkg_resources
import
sys
import
zc.buildout
import
ConfigParser
class
Recipe
(
BaseSlapRecipe
):
def
getTemplateFilename
(
self
,
template_name
):
...
...
@@ -46,15 +48,17 @@ class Recipe(BaseSlapRecipe):
mysql_conf
=
self
.
installMysqlServer
(
self
.
getLocalIPv4Address
(),
45678
)
ca_conf
=
self
.
installCertificateAuthority
()
key
,
certificate
=
self
.
requestCertificate
(
'Login Based Access'
)
stunnel_conf
=
self
.
installStunnel
(
self
.
getGlobalIPv6Address
(),
12345
,
mysql_conf
[
'tcp_port'
],
c
a_conf
[
'ca_certificate'
]
,
ca_conf
[
'ca_crl'
],
c
ertificate
,
ca_conf
[
'ca_crl'
],
ca_conf
[
'certificate_authority_path'
])
self
.
linkBinary
()
self
.
setConnectionDict
(
dict
(
stunnel_ip
=
stunnel_conf
[
'ip'
],
stunnel_port
=
stunnel_conf
[
'
tcp_
port'
],
stunnel_port
=
stunnel_conf
[
'port'
],
mysql_database
=
mysql_conf
[
'mysql_database'
],
mysql_user
=
mysql_conf
[
'mysql_user'
],
mysql_password
=
mysql_conf
[
'mysql_password'
],
...
...
@@ -187,6 +191,18 @@ class Recipe(BaseSlapRecipe):
certificate_authority_path
=
config
[
'ca_dir'
]
)
def
requestCertificate
(
self
,
name
):
hash
=
hashlib
.
sha512
(
name
).
hexdigest
()
key
=
os
.
path
.
join
(
self
.
ca_private
,
hash
+
self
.
ca_key_ext
)
certificate
=
os
.
path
.
join
(
self
.
ca_certs
,
hash
+
self
.
ca_crt_ext
)
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
.
ca_request_dir
,
hash
),
'w'
))
return
key
,
certificate
def
installStunnel
(
self
,
ip
,
port
,
external_port
,
ca_certificate
,
ca_crl
,
ca_path
):
"""Installs stunnel"""
...
...
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