Revision 22114677 lib/utils/x509.py
b/lib/utils/x509.py | ||
---|---|---|
288 | 288 |
|
289 | 289 |
def GenerateSelfSignedSslCert(filename, serial_no, |
290 | 290 |
common_name=constants.X509_CERT_CN, |
291 |
validity=constants.X509_CERT_DEFAULT_VALIDITY): |
|
291 |
validity=constants.X509_CERT_DEFAULT_VALIDITY, |
|
292 |
uid=-1, gid=-1): |
|
292 | 293 |
"""Legacy function to generate self-signed X509 certificate. |
293 | 294 |
|
294 | 295 |
@type filename: str |
... | ... | |
297 | 298 |
@param common_name: commonName value |
298 | 299 |
@type validity: int |
299 | 300 |
@param validity: validity of certificate in number of days |
301 |
@type uid: int |
|
302 |
@param uid: the user ID of the user who will be owner of the certificate file |
|
303 |
@type gid: int |
|
304 |
@param gid: the group ID of the group who will own the certificate file |
|
300 | 305 |
@return: a tuple of strings containing the PEM-encoded private key and |
301 | 306 |
certificate |
302 | 307 |
|
... | ... | |
307 | 312 |
(key_pem, cert_pem) = GenerateSelfSignedX509Cert( |
308 | 313 |
common_name, validity * 24 * 60 * 60, serial_no) |
309 | 314 |
|
310 |
utils_io.WriteFile(filename, mode=0400, data=key_pem + cert_pem) |
|
315 |
utils_io.WriteFile(filename, mode=0440, data=key_pem + cert_pem, |
|
316 |
uid=uid, gid=gid) |
|
311 | 317 |
return (key_pem, cert_pem) |
312 | 318 |
|
313 | 319 |
|
Also available in: Unified diff