selfca

package module
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 17, 2020 License: Apache-2.0 Imports: 11 Imported by: 2

README

SelfCA

License GoDoc Build Status Go Report Card Code Cover

SelfCA is a Go module for self-signed certificate generating.

Overview

Creating your own certificate authority and generating self-signed SSL certificates.

Features

  • Easy to use
  • No openssl required
  • Reuse CA certificate

Installation

go get -u github.com/likexian/selfca

Importing

import (
    "github.com/likexian/selfca"
)

Documentation

Visit the docs on GoDoc

Example

// config for generating CA certificate
config := selfca.Certificate{
    IsCA:          true,
    NotBefore:     time.Now(),
    NotAfter:      time.Now().Add(time.Duration(365) * 24 * time.Hour),
}

// generating the certificate
certificate, key, err := selfca.GenerateCertificate(config)
if err != nil {
    panic(err)
}

// writing the certificate
err = selfca.WriteCertificate("ca", certificate, key)
if err != nil {
    panic(err)
}

License

Copyright 2014-2020 Li Kexian

Licensed under the Apache License 2.0

Donation

If this project is helpful, please share it with friends.

If you want to thank me, you can give me a cup of coffee.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Author added in v0.11.0

func Author() string

Author returns package author

func GenerateCertificate

func GenerateCertificate(c Certificate) ([]byte, *rsa.PrivateKey, error)

GenerateCertificate generates X.509 certificate and key

func License added in v0.11.0

func License() string

License returns package license

func ReadCertificate added in v0.6.0

func ReadCertificate(name string) ([]*x509.Certificate, *rsa.PrivateKey, error)

ReadCertificate reads certificate and key from files

func Version added in v0.11.0

func Version() string

Version returns package version

func WriteCertificate added in v0.4.0

func WriteCertificate(name string, certificate []byte, key *rsa.PrivateKey) error

WriteCertificate writes certificate and key to files

Types

type Certificate

type Certificate struct {
	IsCA          bool
	KeySize       int
	NotBefore     time.Time
	NotAfter      time.Time
	Hosts         []string
	CAKey         *rsa.PrivateKey
	CACertificate *x509.Certificate
}

Certificate stors certificate information for generating

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL