selfca

package module
v0.14.10 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 12 Imported by: 2

README

SelfCA

License GoDoc Go Report Card Build Status Code Cover

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

Overview

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

You can directly using the binary distributions of selfca, follow selfca release tool.

Features

  • Easy to use
  • No openssl required
  • Reuse of CA root 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-2024 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

View Source
var (
	// ErrInvalidCertificate is invalid certificate error
	ErrInvalidCertificate = errors.New("selfca: the certificate is invalid")
	// ErrInvalidCertificateKey is invalid certificate key error
	ErrInvalidCertificateKey = errors.New("selfca: the certificate key is invalid")
)

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
	CommonName    string
	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