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
a265c45e
Commit
a265c45e
authored
11 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
the "autoca" tool can now use a local CA
parent
a0f28b37
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
autoca/ca.py
+1
-0
1 addition, 0 deletions
autoca/ca.py
autoca/ca_stub.py
+1
-0
1 addition, 0 deletions
autoca/ca_stub.py
autoca/ca_tool.py
+29
-7
29 additions, 7 deletions
autoca/ca_tool.py
with
31 additions
and
7 deletions
autoca/ca.py
+
1
−
0
View file @
a265c45e
...
...
@@ -11,6 +11,7 @@ log = logging.getLogger(__name__)
class
CA
(
object
):
"""
A Certification Authority stored on the local filesystem.
"""
def
__init__
(
self
,
root
,
subject
,
bits
=
1024
,
digest
=
'
sha1
'
):
self
.
ca_subject
=
subject
...
...
This diff is collapsed.
Click to expand it.
autoca/ca_stub.py
+
1
−
0
View file @
a265c45e
...
...
@@ -14,6 +14,7 @@ class Error(Exception):
class
CaStub
(
object
):
"""
Client stub for a remote CA.
"""
def
__init__
(
self
,
url
,
secret
=
None
):
self
.
url
=
url
.
rstrip
(
'
/
'
)
...
...
This diff is collapsed.
Click to expand it.
autoca/ca_tool.py
+
29
−
7
View file @
a265c45e
...
...
@@ -3,6 +3,7 @@ import os
import
logging
import
sys
from
OpenSSL
import
crypto
from
autoca
import
ca
from
autoca
import
ca_stub
from
autoca
import
certutil
...
...
@@ -21,6 +22,8 @@ def main():
parser
=
optparse
.
OptionParser
()
parser
.
add_option
(
'
--url
'
,
dest
=
'
url
'
,
help
=
'
autoca API endpoint
'
)
parser
.
add_option
(
'
--ca-path
'
,
dest
=
'
ca_path
'
,
help
=
'
local CA directory
'
)
parser
.
add_option
(
'
--output
'
,
dest
=
'
output
'
,
metavar
=
'
FILE
'
,
help
=
'
write output to this file
'
)
parser
.
add_option
(
'
--outkey
'
,
dest
=
'
outkey
'
,
metavar
=
'
FILE
'
,
...
...
@@ -31,6 +34,10 @@ def main():
parser
.
add_option
(
'
--subject
'
,
dest
=
'
subject
'
,
help
=
'
specify the X.509 subject as a set of
'
'
comma-separated ATTR=VALUE assignments
'
)
parser
.
add_option
(
'
--ca-subject
'
,
dest
=
'
ca_subject
'
,
help
=
'
CA X.509 subject (only on initialization)
'
)
parser
.
add_option
(
'
--ca-bits
'
,
dest
=
'
ca_bits
'
,
type
=
'
int
'
,
default
=
1024
,
help
=
'
CA key size (only on initialization)
'
)
parser
.
add_option
(
'
--secret
'
,
dest
=
'
secret
'
,
help
=
'
shared secret for authentication
'
)
parser
.
add_option
(
'
--days
'
,
dest
=
'
days
'
,
type
=
'
int
'
,
default
=
7
,
...
...
@@ -38,8 +45,10 @@ def main():
opts
,
args
=
parser
.
parse_args
()
if
len
(
args
)
<
1
:
parser
.
error
(
'
No command specified
'
)
if
not
opts
.
url
:
parser
.
error
(
'
Must specify --url
'
)
if
not
opts
.
url
and
not
opts
.
ca_path
:
parser
.
error
(
'
Must specify one of --url or --ca-path
'
)
if
opts
.
url
and
opts
.
ca_path
:
parser
.
error
(
'
Must specify at most one of --url or --ca-path
'
)
secret
=
opts
.
secret
if
not
secret
:
...
...
@@ -47,26 +56,39 @@ def main():
with
open
(
os
.
getenv
(
'
AUTOCA_SECRET
'
),
'
r
'
)
as
fd
:
secret
=
fd
.
read
().
strip
()
ca
=
ca_stub
.
CaStub
(
opts
.
url
,
secret
)
if
opts
.
url
:
client
=
ca_stub
.
CaStub
(
opts
.
url
,
secret
)
else
:
ca_subject
=
None
if
opts
.
ca_subject
:
ca_subject
=
certutil
.
parse_subject
(
opts
.
ca_subject
)
client
=
ca
.
CA
(
opts
.
ca_path
,
ca_subject
,
opts
.
ca_bits
)
cmd
,
args
=
args
[
0
],
args
[
1
:]
if
cmd
==
'
get-ca
'
:
writeout
(
opts
.
output
,
c
a
.
get_ca
())
writeout
(
opts
.
output
,
c
lient
.
get_ca
())
elif
cmd
==
'
get-crl
'
:
fmt
=
'
pem
'
if
args
:
fmt
=
args
[
0
].
lower
()
writeout
(
opts
.
output
,
c
a
.
get_crl
(
format
=
fmt
))
writeout
(
opts
.
output
,
c
lient
.
get_crl
(
format
=
fmt
))
elif
cmd
==
'
sign
'
:
if
not
opts
.
subject
:
parser
.
error
(
'
Must specify --subject
'
)
subject
=
certutil
.
parse_subject
(
opts
.
subject
)
pkey
,
cert
=
c
a
.
make_certificate
(
subject
,
days
=
opts
.
days
,
pkey
,
cert
=
c
lient
.
make_certificate
(
subject
,
days
=
opts
.
days
,
server
=
opts
.
server
)
writeout
(
opts
.
output
,
crypto
.
dump_certificate
(
crypto
.
FILETYPE_PEM
,
cert
))
writeout
(
opts
.
outkey
,
crypto
.
dump_privatekey
(
crypto
.
FILETYPE_PEM
,
pkey
))
elif
cmd
==
'
init
'
:
if
not
opts
.
ca_subject
:
parser
.
error
(
'
Must specify --ca-subject
'
)
if
not
opts
.
ca_path
:
parser
.
error
(
'
The
"
init
"
command is only valid with a local CA
'
)
# Nothing to do, actually.
print
'
Done.
'
else
:
parser
.
error
(
'
Unknown command
'
)
...
...
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