File: SSL-MINI-HOWTO.txt

package info (click to toggle)
mysql-dfsg-4.1 4.1.11a-4sarge8
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 86,724 kB
  • ctags: 78,396
  • sloc: ansic: 380,120; cpp: 348,266; sh: 32,501; tcl: 30,484; perl: 20,873; yacc: 5,447; java: 4,610; makefile: 4,406; xml: 3,857; pascal: 1,795; awk: 1,338; asm: 1,064; sed: 772; sql: 503
file content (164 lines) | stat: -rw-r--r-- 5,156 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164

The following text is a mini guide howto setup basic encrypted mysql
service. For more information search the MySQL and OpenSSL documentation.

Please not that OpenSSL is no longer enabled by default so you have to
rebuild the package yourself to get it work. See changelog.Debian enty
from 2004-12-02 for reasons.

<ch@debian.org>

--------------------------------------------------------------------------

0. Change to the mysql ssl directory
	cd /etc/mysql/ssl/

#
# Setup your own Certification Authority
#
1. Create your own Certification Authority (CA) if you do not already have
   one (e.g. for signing web or mail server certificates)
	openssl req -x509 -new -days 9999 -newkey rsa:2048 -nodes \
	   -keyout ca-key.pem \
	   -out ca-cert.pem
	
#
# Create a server certificate
#
	   
2a. Create the server certificate request
	openssl req -new -newkey rsa:2048 -nodes \
	  -keyout server-key.pem \
	  -out server-csr.pem 

2b. Sign this server request with the CA key to make a proper server certificate.
	openssl x509 -req -days 9999 \
	  -CA ca-cert.pem -CAkey ca-key.pem -CAcreateserial -CAserial ca-srl.txt \
	  -in server-csr.pem \
	  -out server-cert.pem

2b. Adjust the following lines in /etc/mysql/my.cnf according to your needs:
	[mysqld]
	ssl-key=/etc/mysql/ssl/server-key.pem
	ssl-cert=/etc/mysql/ssl/server-cert.pem
	ssl-ca=/etc/mysql/ssl/ca-cert.pem


#
# Create the client certificates
# 
3a. Create the client certificate request
	openssl req -new -newkey rsa:2048 -nodes \
	  -keyout client-key.pem \
	  -out client-csr.pem 

3b. Sign this server request with the CA key to make a proper server certificate.
	openssl x509 -req -days 9999 \
	  -CA ca-cert.pem -CAkey ca-key.pem -CAcreateserial -CAserial ca-srl.txt \
	  -in client-csr.pem \
	  -out client-cert.pem
	
3c. Now move the client* files to the client machine and adjust the users ~/.my.cnf
    or client hosts /etc/mysql/my.cnf:
	[client]
	ssl-key=/home/ch/client-key.pem
	ssl-cert=/home/ch/client-cert.pem

#
# Now configure SSL login constrains.
# 
4.a This allowes passwordless login if the cryptographic key, the client 
    ("subject") uses, was certified by our CA ("issuer") to belong to 
    the user it claims to.
    Don't be so lazy to just limit to a subject because without checking
    the issuer - whom's key only we have - anybody could fake the subject
    line rendering the whole thing nearly useless.
    	GRANT all 
	ON *.* 
	TO "my"
	REQUIRE
	  subject "/C=DE/ST=NRW/L=Aachen/CN=Foo Bar/emailAddress=foobar@example.com" and 
	  issuer "/C=DE/ST=NRW/L=Aachen/CN=Christian Hammers/emailAddress=ch@debian.org";

4.b Don't forget this one:
	FLUSH PRIVILEGES;

The following text is a mini guide howto setup basic encrypted mysql
service. For more information search the MySQL and OpenSSL documentation.

<ch@debian.org>

--------------------------------------------------------------------------

0. Change to the mysql ssl directory
	cd /etc/mysql/ssl/

#
# Setup your own Certification Authority
#
1. Create your own Certification Authority (CA) if you do not already have
   one (e.g. for signing web or mail server certificates)
	openssl req -x509 -new -days 9999 -newkey rsa:2048 -nodes \
	   -keyout ca-key.pem \
	   -out ca-cert.pem
	
#
# Create a server certificate
#
	   
2a. Create the server certificate request
	openssl req -new -newkey rsa:2048 -nodes \
	  -keyout server-key.pem \
	  -out server-csr.pem 

2b. Sign this server request with the CA key to make a proper server certificate.
	openssl x509 -req -days 9999 \
	  -CA ca-cert.pem -CAkey ca-key.pem -CAcreateserial -CAserial ca-srl.txt \
	  -in server-csr.pem \
	  -out server-cert.pem

2b. Adjust the following lines in /etc/mysql/my.cnf according to your needs:
	[mysqld]
	ssl-key=/etc/mysql/ssl/server-key.pem
	ssl-cert=/etc/mysql/ssl/server-cert.pem
	ssl-ca=/etc/mysql/ssl/ca-cert.pem


#
# Create the client certificates
# 
3a. Create the client certificate request
	openssl req -new -newkey rsa:2048 -nodes \
	  -keyout client-key.pem \
	  -out client-csr.pem 

3b. Sign this server request with the CA key to make a proper server certificate.
	openssl x509 -req -days 9999 \
	  -CA ca-cert.pem -CAkey ca-key.pem -CAcreateserial -CAserial ca-srl.txt \
	  -in client-csr.pem \
	  -out client-cert.pem
	
3c. Now move the client* files to the client machine and adjust the users ~/.my.cnf
    or client hosts /etc/mysql/my.cnf:
	[client]
	ssl-key=/home/ch/client-key.pem
	ssl-cert=/home/ch/client-cert.pem

#
# Now configure SSL login constrains.
# 
4.a This allowes passwordless login if the cryptographic key, the client 
    ("subject") uses, was certified by our CA ("issuer") to belong to 
    the user it claims to.
    Don't be so lazy to just limit to a subject because without checking
    the issuer - whom's key only we have - anybody could fake the subject
    line rendering the whole thing nearly useless.
    	GRANT all 
	ON *.* 
	TO "my"
	REQUIRE
	  subject "/C=DE/ST=NRW/L=Aachen/CN=Foo Bar/emailAddress=foobar@example.com" and 
	  issuer "/C=DE/ST=NRW/L=Aachen/CN=Christian Hammers/emailAddress=ch@debian.org";

4.b Don't forget this one:
	FLUSH PRIVILEGES;