Code Monkey home page Code Monkey logo

cades's Introduction

CAdES

Utility class to sign files width CAdES-BES (CMS Advanced Electronic Signatures) digital signature.

The library provides the following classes:

  • org.dew.cades.CAdESSigner - CAdES Signer by keystore
  • org.dew.cades.CAdESSignerSC - CAdES Signer by smartcard

Example

CAdESSigner cades = new CAdESSigner("keystore.jks", "password", "selfsigned");

cades.sign("file.xml");

Manage certificates using Java Keytool

Generate a Self Signed Certificate

keytool -genkey -keyalg RSA -alias selfsigned -keystore keystore.jks -storepass password -validity 365 -keysize 2048

Convert keystore from JKS to PKCS12

keytool -importkeystore -srckeystore keystore.jks -destkeystore keystore.p12 -deststoretype PKCS12 -srcalias selfsigned -srcstorepass password -deststorepass password -destkeypass password

List certificates

keytool -list -keystore keystore.jks -storepass password

View certificates

keytool -list -rfc -alias selfsigned -keystore keystore.jks -storepass password

Export certificates

keytool -export -alias selfsigned -keystore keystore.jks -storepass password -file selfsigned.cer

Import certificates

keytool -import -file test.pem -alias test -keystore keystore.jks -storepass password

Delete certificates

keytool -delete -alias test -keystore keystore.jks -storepass password

Generate a CSR (Certificate Signing Request)

keytool –keystore keystore.jks –certreq –alias selfsigned –keyalg RSA –file req.csr

Import CA response

keytool -importcert -trustcacerts -file cacert.pem –keystore keystore.jks -alias selfsigned

Manage private key and certificates using openssl

Generate a 2048-bit RSA private key and CSR (Certificate Signing Request)

openssl req -newkey rsa:2048 -keyout pkey.pem -out req.csr

Generate a 2048-bit RSA private key with Self-Signed Certificate

openssl req -newkey rsa:2048 -keyout pkey.pem -nodes -x509 -days 365 -out cert.crt

Create keystore.p12 in PKCS12 format

openssl pkcs12 -export -in cert.pem -inkey pkey.pem -name shared -out keystore.p12

Create keystore.p12 in PKCS12 format width intermediate certificates (icert.pem)

openssl pkcs12 -export -in cert.pem -inkey pkey.pem -certfile icert.pem -name shared -out keystore.p12

View certificates in keystore.p12

openssl pkcs12 -in keystore.p12 -nokeys -info -passin pass:password

Export certificates from keystore.p12

openssl pkcs12 -in keystore.p12 -nokeys -out cert.pem

Export private key from keystore.p12

openssl pkcs12 -in keystore.p12 -nodes -nocerts -out pkey.pem

Convert PEM certificate to DER

openssl x509 -in cert.pem -outform der -out cert.crt

Convert DER certificate to PEM

openssl x509 -inform der -in cert.crt -out cert.pem

Convert private key in RSA private key

openssl rsa -in pkey.pem -out rkey.pem

Convert keystore from PKCS12 to JKS

keytool -importkeystore -srckeystore keystore.p12 -srcstoretype pkcs12 -srcalias shared -destkeystore keystore.jks -deststoretype jks -deststorepass password -destalias shared

Build

  • git clone https://github.com/giosil/cades.git
  • mvn clean install

Contributors

cades's People

Contributors

giosil avatar

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.