Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
autoca
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
ai
autoca
Commits
c378f69c
Commit
c378f69c
authored
11 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
add a method to renew a CA certificate
parent
0bce6d0c
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
autoca/ca.py
+31
-21
31 additions, 21 deletions
autoca/ca.py
with
31 additions
and
21 deletions
autoca/ca.py
+
31
−
21
View file @
c378f69c
...
...
@@ -20,17 +20,7 @@ class CA(object):
self
.
_init_ca
()
self
.
_load_crl
()
def
_init_ca
(
self
):
key_str
,
crt_str
=
self
.
storage
.
get_ca
()
if
key_str
:
self
.
ca_key
=
crypto
.
load_privatekey
(
crypto
.
FILETYPE_PEM
,
key_str
)
self
.
ca_crt
=
crypto
.
load_certificate
(
crypto
.
FILETYPE_PEM
,
crt_str
)
self
.
public_ca_pem
=
crt_str
else
:
log
.
info
(
'
initializing CA certificate and private key
'
)
self
.
ca_key
=
certutil
.
create_rsa_key_pair
(
self
.
bits
)
def
_generate_ca_cert
(
self
):
ca_req
=
certutil
.
create_cert_request
(
self
.
ca_key
,
**
(
self
.
ca_subject
))
self
.
ca_crt
=
certutil
.
sign_certificate
(
...
...
@@ -52,6 +42,26 @@ class CA(object):
crt_str
)
self
.
public_ca_pem
=
crt_str
def
_init_ca
(
self
):
key_str
,
crt_str
=
self
.
storage
.
get_ca
()
if
key_str
:
self
.
ca_key
=
crypto
.
load_privatekey
(
crypto
.
FILETYPE_PEM
,
key_str
)
self
.
ca_crt
=
crypto
.
load_certificate
(
crypto
.
FILETYPE_PEM
,
crt_str
)
self
.
public_ca_pem
=
crt_str
else
:
log
.
info
(
'
initializing CA certificate and private key
'
)
self
.
ca_key
=
certutil
.
create_rsa_key_pair
(
self
.
bits
)
self
.
_generate_ca_cert
()
def
renew_ca
(
self
):
if
not
self
.
ca_key
:
log
.
error
(
'
CA private key not available
'
)
return
log
.
info
(
'
renewing CA certificate
'
)
self
.
_generate_ca_cert
()
def
get_ca
(
self
):
return
self
.
public_ca_pem
...
...
@@ -77,7 +87,7 @@ class CA(object):
crypto
.
X509Extension
(
'
extendedKeyUsage
'
,
False
,
server
and
'
serverAuth
'
or
'
clientAuth
'
),
crypto
.
X509Extension
(
'
nsCertType
'
,
False
,
server
and
'
server
'
or
'
client
'
),
server
and
'
client,
server
'
or
'
client
'
),
]
cert
=
certutil
.
sign_certificate
(
req
,
self
.
ca_key
,
self
.
ca_crt
,
new_serial
,
days
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment