_storage

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index

Constants

View Source
const (
	PEMFile       = "key.pem"
	PublicPEMFile = "key.pub"
)

File name constants

Variables

View Source
var ErrIncompleteCopy = errors.New("file copy was incomplete")

Functions

func CAPathIsReady

func CAPathIsReady() (string, error)

func CAStorage

func CAStorage(commonName string) bool

func CheckCertExists

func CheckCertExists(f File) bool

CheckCertExists returns if a certificate exists or not

func CopyFile added in v1.2.0

func CopyFile(src, dest string) error

CopyFile copies the specified src file to the given destination. Both paths are relative to the $CAPATH hierarchy.

func ListCAs added in v1.0.2

func ListCAs() []string

ListCAs return a list of certificates folders

func ListCertificates

func ListCertificates(CACommonName string) []string

ListCertificates return a list of certificates folders

func LoadFile

func LoadFile(filePath ...string) ([]byte, error)

LoadFile loads a file by file name from $CAPATH

func MakeFolder

func MakeFolder(folderPath ...string) error

MakeFolder creates folder inside the CAPATH infrastructure.

func SaveFile

func SaveFile(f File) error

SaveFile saves a File{}

Types

type CreationType

type CreationType int

CreationType represents if CA or Certificate owns the file

const (
	// CreationTypeCA owned by CA
	CreationTypeCA CreationType = 1 << iota
	// CreationTypeCertificate owned by Certificate
	CreationTypeCertificate
)

type File

type File struct {
	CA             string
	CommonName     string
	FileType       FileType
	PrivateKeyData *rsa.PrivateKey
	PublicKeyData  rsa.PublicKey
	CSRData        []byte
	CertData       []byte
	CRLData        []byte
	CreationType   CreationType
}

File has the content to save a file

type FileType

type FileType int

FileType represents what type of file

const (
	// FileTypeKey is Key files
	FileTypeKey FileType = 1 << iota
	// FileTypeCSR is a Certificate Signging Request file
	FileTypeCSR
	// FileTypeCertificate is a Certificate file
	FileTypeCertificate
	// FileTypeCRL is a Certificate Revoking List file
	FileTypeCRL
)

Jump to

Keyboard shortcuts

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