Documentation ¶
Overview ¶
Package generator defines a generator used to create certificate and private key.
Index ¶
- type Closer
- type CreateOptions
- type FileWriter
- type Generator
- func (g *Generator) CA() (ca *x509.Certificate, pkey crypto.PrivateKey)
- func (g *Generator) Create(c *crt.Certificate) (cert []byte, pkey []byte, err error)
- func (g *Generator) CreateAndWrite(w WriteCloser, c *crt.Certificate) error
- func (g *Generator) CreateWithOptions(c *crt.Certificate, opts CreateOptions) (cert []byte, pkey []byte, err error)
- func (g *Generator) SetCA(ca *x509.Certificate, pkey crypto.PrivateKey)
- type Option
- type WriteCloser
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Closer ¶ added in v0.2.2
type Closer interface {
Close() error
}
Closer is the interface that wraps the basic Close method.
type CreateOptions ¶ added in v0.1.11
type CreateOptions struct { G key.Generator KeyOpts *key.MarshalOptions UseAsCA bool AppendCA bool }
CreateOptions defines options for Generator.Create. UseAsCA if true, the given crt.Certificate will be used as the CA certificate for the Generator. If the crt.Certificate is not CA type, UseAsCA will be ignored. AppendCA if true, the CA certificate of the Generator will append to the result.
type FileWriter ¶
type FileWriter struct {
// contains filtered or unexported fields
}
FileWriter implements Writer interface.
func NewFileWriter ¶
func NewFileWriter(certfile, prikfile *os.File) *FileWriter
NewFileWriter creates a new FileWriter with certificate *os.File and private key *os.File.
func NewFileWriterFromPaths ¶ added in v0.2.2
func NewFileWriterFromPaths(certfile, prikfile string) (*FileWriter, error)
NewFileWriterFromPaths creates a new FileWriter with the given certificate and private key paths.
func (*FileWriter) Close ¶ added in v0.2.2
func (fw *FileWriter) Close() error
Close implements Closer interface.
func (*FileWriter) Write ¶
func (fw *FileWriter) Write(cert, prik []byte) error
Write implements Writer interface.
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator is the main structure of a generator.
func (*Generator) CA ¶ added in v0.1.9
func (g *Generator) CA() (ca *x509.Certificate, pkey crypto.PrivateKey)
CA returns the CA pair of the Generator.
func (*Generator) Create ¶
Create creates a new X.509 v3 certificate and private key based on a template.
func (*Generator) CreateAndWrite ¶
func (g *Generator) CreateAndWrite(w WriteCloser, c *crt.Certificate) error
CreateAndWrite creates a new X.509 v3 certificate and private key, then execute the Writer.Write.
func (*Generator) CreateWithOptions ¶ added in v0.1.11
func (g *Generator) CreateWithOptions(c *crt.Certificate, opts CreateOptions) (cert []byte, pkey []byte, err error)
CreateWithOptions creates a new X.509 v3 certificate and private key based on a template with the given CreateOptions.
func (*Generator) SetCA ¶
func (g *Generator) SetCA(ca *x509.Certificate, pkey crypto.PrivateKey)
SetCA is used to set the CA pair of the Generator.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option defines optional parameters for initializing the generator structure.
func WithCA ¶
func WithCA(ca *x509.Certificate, key crypto.PrivateKey) Option
WithCA is used to set the CA pair of the Generator.
func WithKeyGenerator ¶ added in v0.1.1
WithKeyGenerator is used to set the private key generator of the Generator.
type WriteCloser ¶ added in v0.2.2
WriteCloser is the interface that groups the basic Write and Close methods.