GithubHelp home page GithubHelp logo

lilik-117bis / ca_manager Goto Github PK

View Code? Open in Web Editor NEW
4.0 4.0 1.0 178 KB

Easier Certification Authority management

License: GNU General Public License v3.0

Python 100.00%
certification authority ansible json ssh ssl

ca_manager's Introduction

CA manager

it's true

This collection of tools is our take on managing a CA, signing SSH keys and certificates, signin SSL certificates.

Install

Install from pip with the latest release

Scripts

With the library are distributed the following scripts

ca-server

This is a shell for a user, the shell only reads the input from the user and return a JSON, this user can be used with Ansible to request and retrieve certificates.

The server logs can be found at /home/request/request_server.log

A playbook example can be found in ansible.yaml

ca-shell

This is a shell for a user, the shell limits the commands to the one we are interested, like generating a SSH/SSL CA, signing keys.

Debug

You can provide a request to the server using the command

python test/make_ssh_user_request.py /path/to/your_public_key.pub your_name | ca-server

This will work for any script in the test directory

ca_manager's People

Contributors

cimbalo avatar edoput avatar slash3g avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

bellyfat

ca_manager's Issues

Hostname not found

Signin a certificate from the new ssh_server role shows that we have a problem with hostnames

CA Manager)> sign_request test_ssh_ca d9a183bd-0def-4ad6-9aae-b9e3acd912ab 
Request hash: 295de20c36094c862c1cc7a30321eabaee420440ac0f71531de5000932b6bcf9
You are about to sign the following request:
  HostSSHRequest d9a183bd-0def-4ad6-9aae-b9e3acd912ab with fields: [('Hostname', '.lilik.it')]
with the following CA:
  SSHAuthority test_ssh_ca (ca di test per ssh), created on 2017-03-20 21:31:37.922499
Proceed? (type yes)> yes
Enter passphrase: 
Signed host key /var/lib/ca_manager/outputs/d9a183bd-0def-4ad6-9aae-b9e3acd912ab-cert.pub: id "host__lilik_it" serial 0 for .lilik.it valid from 2017-04-10T15:38:00 to 2018-04-09T15:39:11

As you can see the hostname has been splitted and we have ".lilik.it" instead of "hostname.lilik.it"

cannot set root ca from shell

Version from tag v0.1 cannot set the root flag

(CA Manager)> gen_ssh xxssh test
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/peewee.py", line 3768, in execute_sql
    cursor.execute(sql, params or ())
sqlite3.IntegrityError: NOT NULL constraint failed: sshauthority.isRoot

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/ca-shell", line 20, in <module>
    CAManagerShell(ca_manager).cmdloop()
  File "/usr/lib/python3.5/cmd.py", line 138, in cmdloop
    stop = self.onecmd(line)
  File "/usr/lib/python3.5/cmd.py", line 217, in onecmd
    return func(arg)
  File "/usr/local/lib/python3.5/dist-packages/ca_manager/shell.py", line 176, in do_gen_ssh
    new_auth.save()
  File "/usr/local/lib/python3.5/dist-packages/peewee.py", line 5108, in save
    pk_from_cursor = self.insert(**field_dict).execute()
  File "/usr/local/lib/python3.5/dist-packages/peewee.py", line 3526, in execute
    cursor = self._execute()
  File "/usr/local/lib/python3.5/dist-packages/peewee.py", line 2912, in _execute
    return self.database.execute_sql(sql, params, self.require_commit)
  File "/usr/local/lib/python3.5/dist-packages/peewee.py", line 3775, in execute_sql
    self.commit()
  File "/usr/local/lib/python3.5/dist-packages/peewee.py", line 3598, in __exit__
    reraise(new_type, new_type(*exc_args), traceback)
  File "/usr/local/lib/python3.5/dist-packages/peewee.py", line 135, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.5/dist-packages/peewee.py", line 3768, in execute_sql
    cursor.execute(sql, params or ())
peewee.IntegrityError: NOT NULL constraint failed: sshauthority.isRoot

SSH: Separate host CA from user CA

We should really do this. The host CA can still be available to ansible but the user CA should not.

Moreover we should then separate them in the ansible playbook too

Signed by field not found

When asked to describe a certificate the command raises a AttributeError

(CA Manager)> describe_certificate d9a183bd-0def-4ad6-9aae-b9e3acd912ab 
Traceback (most recent call last):
  File "/home/sign/ca_manager/manager.py", line 114, in <module>
    CAManagerShell(ca_manager).cmdloop()
  File "/usr/lib/python3.5/cmd.py", line 138, in cmdloop
    stop = self.onecmd(line)
  File "/usr/lib/python3.5/cmd.py", line 217, in onecmd
    return func(arg)
  File "/home/sign/ca_manager/shell.py", line 98, in do_describe_certificate
    cert.signed_by,
AttributeError: 'Certificate' object has no attribute 'signed_by'

Authority model should output a certificate signin request

As we will, hopefully, have a root certification authority we should generate not simple files but certificate signin requests.

We can convert from openssl to openssh key format with ssh-keygen -f private.pem -y > private.pub so we can move the generate method to the Authority base class

Use pickle instead of JSON as request storage

In https://github.com/LILiK-117bis/ca_manager/blob/master/ca_manager.py#L123 and https://github.com/LILiK-117bis/ca_manager/blob/master/request_server.py#L73 we are basically dumping and loading JSON instead of using the pickle format.

Using the pickle format we can drop this deserialisation in https://github.com/LILiK-117bis/ca_manager/blob/master/ca_manager.py#L136 using some metaprogramming but the server would be dependent on the SignRequest class.

Key revocation list command missing

We can currently sign ssh keys but are unable to revoke them.

Certificates can be revoked with one of two inputs:

  • by key ID
  • by certificate serial

the command is ssh-keygen -s /path/to/ca.pub -k create a KRL, the command ssh-keygen -s /paht/to/ca.pub -u update a previous KRL

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.