Skip to main content

A Python SCEP client and server

Project description

PyScep

A Python SCEP Client library to enrol for certificate from a SCEP CA.

Note: It is intended to be used for testing the environments

Getting Started

Prerequisite

Either Generate a Self Signed Certificate or use an existing Certificate issued by CA

Generate a Self Signed Certificate

identity, identity_private_key = Client.SigningRequest.generate_self_signed(
    cn=u'PyScep-test',
    key_usage={u'digital_signature', u'key_encipherment'}
)

Note: this will generate a new RSA Key pair automatically, you can optionally supply a private_key.

Load an Existing Certificate

identity, identity_private_key = Client.Certificate.from_p12_file(
    p12_file='/path/to/cert.p12', 
    password='password'
)

Signing Request

csr, private_key = Client.SigningRequest.generate_csr(
    cn=u'PyScep-test', 
    key_usage={u'digital_signature', u'key_encipherment'}, 
    password='password' 
)

Note: this will generate a new RSA Key pair automatically, you can optionally supply a private_key.

Creating a Client

client = Client.Client(
    'http://<hostname>:<port>/ejbca/publicweb/apply/scep/pkiclient.exe'
)

Above example creates a sample client for EJBCA. Please update the path according to the CA server in use.

Enrollment

res = client.enrol(
    csr=csr,
    identity=identity, 
    identity_private_key=identity_private_key, 
    identifier=identifier ## An optional identifier how CA Server identifies the CA
)

if res.status == PKIStatus.FAILURE:
    print res.fail_info
elif res.status == PKIStatus.PENDING:
    print res.transaction_id
else:
    print res.certificate

Poll

res = client.poll(
    identity=identity,
    identity_private_key=identity_private_key,
    subject=subject,
    transaction_id=transaction_id 
)

Response is same as Enrollment.

Get Certificate

res = client.get_cert(
    identity=identity,
    identity_private_key=identity_private_key,
    serial_number=1234567890
)

Response is same as Enrollment.

CRL

res = client.get_crl(
    identity=identity,
    identity_private_key=identity_private_key, 
    serial_number=1234567890
)

if res.status == PKIStatus.FAILURE:
    print res.fail_info
elif res.status == PKIStatus.PENDING:
    print res.transaction_id
else:
    print res.crl

Get Rollover Certificate

ca_certificate = client.rollover_certificate()

Credits

SCEPy for providing base implementation for this project

jscep for interface

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

PyScep-0.0.4-py2-none-any.whl (25.0 kB view details)

Uploaded Python 2

File details

Details for the file PyScep-0.0.4-py2-none-any.whl.

File metadata

  • Download URL: PyScep-0.0.4-py2-none-any.whl
  • Upload date:
  • Size: 25.0 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.7.0 requests/2.24.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/2.7.16

File hashes

Hashes for PyScep-0.0.4-py2-none-any.whl
Algorithm Hash digest
SHA256 894b0f94d8f5dedecd752b683c5a3dfdc3506216bd3e46373598041548079666
MD5 34886ead4ec3833f39681bd01197f78a
BLAKE2b-256 17d02fe7d5e38adc2b0608208470ce03ecc525e864509a6be121798d3f19d7f9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page