Giter Club home page Giter Club logo

gocertsigner's Introduction

Go Report Card

Name    : GoCertSigner Library                      
Author  : Noah Shibley, http://socialhardware.net                       
Date    : July 8th 2014                                 
Version : 0.1                                               
Notes   : A cgo layer that uses openssl to produce pkcs7 signatures for golang
Dependencies:   openssl or libressl: libcrypto

Function List:

//signs a document using a p12 cert producing a pkcs7 signature
SignWithP12(doc []byte, pkcs12 []byte, pkcsPass string, caCert []byte) (signature []byte, err error) 
        
//signs a document using a x509 der cert with a pem Key producing a pkcs7 signature
SignWithX509PEM(doc []byte, x509Cert []byte, pemKey []byte, keyPass string, caCert []byte) (signature []byte, err error)

Example:

package main

import (
        s "github.com/nullboundary/gocertsigner"
        "io/ioutil"
        "log"
)

func main() {

        //get doc to sign
        doc, err := ioutil.ReadFile("myfile.txt")
        if err != nil {
                log.Printf("error: %s", err)
        }

        //your pkcs12 certificate
        p12, err := ioutil.ReadFile("testCert.p12")
        if err != nil {
                log.Printf("error: %s", err)

        }

        //your certificate authority cert
        caCert, err := ioutil.ReadFile("ca.cer")
        if err != nil {
                log.Printf("error: %s", err)

        }

        //your cert password. Store somewhere safe, not in code.
        p12pass := "yourCertPassword"

        //create the signature
        signature, err := s.SignWithP12(doc, p12, p12pass, caCert)
        if err != nil {
                log.Printf("error: %s", err)
        }

        //write out to disk
        ioutil.WriteFile("Signature", signature, 0644)
        if err != nil {
                log.Printf("error: %s", err)
        }

}

gocertsigner's People

Contributors

nullboundary avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

fishgege

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.