lib

package
v0.0.0-...-e171dc0 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2018 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToX509Cert

func BytesToX509Cert(bytes []byte) (*x509.Certificate, error)

BytesToX509Cert converts bytes (PEM or DER) to an X509 certificate

func GetAttrValue

func GetAttrValue(attrs []api.Attribute, name string) string

GetAttrValue searches 'attrs' for the attribute with name 'name' and returns its value, or "" if not found.

func GetCertID

func GetCertID(bytes []byte) (string, string, error)

GetCertID returns both the serial number and AKI (Authority Key ID) for the certificate

func LoadPEMCertPool

func LoadPEMCertPool(certFiles []string) (*x509.CertPool, error)

LoadPEMCertPool loads a pool of PEM certificates from list of files

func NormalizeURL

func NormalizeURL(addr string) (*url.URL, error)

NormalizeURL normalizes a URL (from cfssl)

func UnmarshalConfig

func UnmarshalConfig(config interface{}, vp *viper.Viper, configFile string, server, viperIssue327WorkAround bool) error

UnmarshalConfig will use the viperunmarshal workaround to unmarshal a configuration file into a struct

Types

type CAConfig

type CAConfig struct {
}

CAConfig ...

type Client

type Client struct {
	// The client's home directory
	HomeDir string `json:"homeDir,omitempty"`
	// The client's configuration
	Config *ClientConfig
	// contains filtered or unexported fields
}

Client is the fabric-ca client object

func (*Client) CheckEnrollment

func (c *Client) CheckEnrollment() error

CheckEnrollment returns an error if this client is not enrolled

func (*Client) Enroll

func (c *Client) Enroll(req *api.EnrollmentRequest) (*EnrollmentResponse, error)

Enroll enrolls a new identity @param req The enrollment request

func (*Client) GenCSR

func (c *Client) GenCSR(req *api.CSRInfo, id string) ([]byte, bccsp.Key, error)

GenCSR generates a CSR (Certificate Signing Request)

func (*Client) GetCAInfo

func (c *Client) GetCAInfo(req *api.GetCAInfoRequest) (*GetServerInfoResponse, error)

GetCAInfo returns generic CA information

func (*Client) GetCertFilePath

func (c *Client) GetCertFilePath() string

GetCertFilePath returns the path to the certificate file for this client

func (*Client) Init

func (c *Client) Init() error

Init initializes the client

func (*Client) LoadCSRInfo

func (c *Client) LoadCSRInfo(path string) (*api.CSRInfo, error)

LoadCSRInfo reads CSR (Certificate Signing Request) from a file @parameter path The path to the file contains CSR info in JSON format

func (*Client) LoadIdentity

func (c *Client) LoadIdentity(keyFile, certFile string) (*Identity, error)

LoadIdentity loads an identity from disk

func (*Client) LoadMyIdentity

func (c *Client) LoadMyIdentity() (*Identity, error)

LoadMyIdentity loads the client's identity from disk

func (*Client) NewIdentity

func (c *Client) NewIdentity(key bccsp.Key, cert []byte) (*Identity, error)

NewIdentity creates a new identity

func (*Client) SendReq

func (c *Client) SendReq(req *http.Request, result interface{}) (err error)

SendReq sends a request to the fabric-ca-server and fills in the result

func (*Client) StoreMyIdentity

func (c *Client) StoreMyIdentity(cert []byte) error

StoreMyIdentity stores my identity to disk

type ClientConfig

type ClientConfig struct {
	Debug      bool   `def:"false" opt:"d" help:"Enable debug level logging"`
	URL        string `def:"http://localhost:7054" opt:"u" help:"URL of fabric-ca-server"`
	MSPDir     string `def:"msp" opt:"M" help:"Membership Service Provider directory"`
	TLS        tls.ClientTLSConfig
	Enrollment api.EnrollmentRequest
	CSR        api.CSRInfo
	ID         api.RegistrationRequest
	Revoke     api.RevocationRequest
	CAInfo     api.GetCAInfoRequest
	CAName     string               `help:"Name of CA"`
	CSP        *factory.FactoryOpts `mapstructure:"bccsp"`
}

ClientConfig is the fabric-ca client's config

func (*ClientConfig) Enroll

func (c *ClientConfig) Enroll(rawurl, home string) (*EnrollmentResponse, error)

Enroll a client given the server's URL and the client's home directory. The URL may be of the form: http://user:pass@host:port where user and pass are the enrollment ID and secret, respectively.

type EnrollmentResponse

type EnrollmentResponse struct {
	Identity   *Identity
	ServerInfo GetServerInfoResponse
}

EnrollmentResponse is the response from Client.Enroll and Identity.Reenroll

type GetServerInfoResponse

type GetServerInfoResponse struct {
	// CAName is the name of the CA
	CAName string
	// CAChain is the PEM-encoded bytes of the fabric-ca-server's CA chain.
	// The 1st element of the chain is the root CA cert
	CAChain []byte
}

GetServerInfoResponse is the response from the GetServerInfo call

type Identity

type Identity struct {
	CSP bccsp.BCCSP
	// contains filtered or unexported fields
}

Identity is fabric-ca's implementation of an identity

func (*Identity) GetClient

func (i *Identity) GetClient() *Client

GetClient returns the client associated with this identity

func (*Identity) GetECert

func (i *Identity) GetECert() *Signer

GetECert returns the enrollment certificate signer for this identity

func (*Identity) GetName

func (i *Identity) GetName() string

GetName returns the identity name

func (*Identity) GetTCertBatch

func (i *Identity) GetTCertBatch(req *api.GetTCertBatchRequest) ([]*Signer, error)

GetTCertBatch returns a batch of TCerts for this identity

func (*Identity) Post

func (i *Identity) Post(endpoint string, reqBody []byte, result interface{}) error

Post sends arbtrary request body (reqBody) to an endpoint. This adds an authorization header which contains the signature of this identity over the body and non-signature part of the authorization header. The return value is the body of the response.

func (*Identity) Reenroll

Reenroll reenrolls an existing Identity and returns a new Identity @param req The reenrollment request

func (*Identity) Register

func (i *Identity) Register(req *api.RegistrationRequest) (rr *api.RegistrationResponse, err error)

Register registers a new identity @param req The registration request

func (*Identity) RegisterAndEnroll

func (i *Identity) RegisterAndEnroll(req *api.RegistrationRequest) (*Identity, error)

RegisterAndEnroll registers and enrolls an identity and returns the identity

func (*Identity) Revoke

func (i *Identity) Revoke(req *api.RevocationRequest) error

Revoke the identity associated with 'id'

func (*Identity) RevokeSelf

func (i *Identity) RevokeSelf() error

RevokeSelf revokes the current identity and all certificates

func (*Identity) Store

func (i *Identity) Store() error

Store writes my identity info to disk

type ServerConfig

type ServerConfig struct {
	CAcfg CAConfig `skip:"true"`
}

ServerConfig ...

type Signer

type Signer struct {
	// contains filtered or unexported fields
}

Signer represents a signer Each identity may have multiple signers, currently one ecert and multiple tcerts

func (*Signer) Cert

func (s *Signer) Cert() []byte

Cert returns the cert bytes of this signer

func (*Signer) Key

func (s *Signer) Key() bccsp.Key

Key returns the key bytes of this signer

func (*Signer) RevokeSelf

func (s *Signer) RevokeSelf() error

RevokeSelf revokes only the certificate associated with this signer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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