Documentation ¶
Overview ¶
Package access contains structs for storing chaincode access control information
Index ¶
- Variables
- func CertEqual(cert1, cert2 SubjectIssuer) error
- func CertSubjEqual(a, b []byte) (bool, error)
- func Certificate(c []byte) (cert *x509.Certificate, err error)
- func Equal(identity1, identity2 IdentityAttrs) error
- func GetDN(name *pkix.Name) string
- func ID(subject, issuer string) string
- func IDByCert(cert *x509.Certificate) string
- func IDRaw(subject, issuer string) string
- func MarshalPublicKey(publicKey interface{}) []byte
- func PrivateKey(keyBytes []byte) (*ecdsa.PrivateKey, error)
- type CertIdentity
- func (ci CertIdentity) Anonymous() bool
- func (ci CertIdentity) ExpiresAt() time.Time
- func (ci CertIdentity) GetID() string
- func (ci CertIdentity) GetIdentifier() *msp.IdentityIdentifier
- func (ci CertIdentity) GetIssuer() string
- func (ci CertIdentity) GetMSPIdentifier() string
- func (ci CertIdentity) GetOrganizationalUnits() []*msp.OUIdentifier
- func (ci CertIdentity) GetPEM() []byte
- func (ci CertIdentity) GetPublicKey() interface{}
- func (ci CertIdentity) GetPublicVersion() msp.Identity
- func (ci CertIdentity) GetSubject() string
- func (ci CertIdentity) SatisfiesPrincipal(principal *protomsp.MSPPrincipal) error
- func (ci CertIdentity) Serialize() ([]byte, error)
- func (ci CertIdentity) Sign(msg []byte) ([]byte, error)
- func (ci CertIdentity) ToBytes() ([]byte, error)
- func (ci CertIdentity) ToSerialized() *protomsp.SerializedIdentity
- func (ci CertIdentity) Validate() error
- func (ci CertIdentity) Verify(msg []byte, sig []byte) error
- type Entry
- func (e Entry) GetID() string
- func (e Entry) GetIdentityEntry() Entry
- func (e Entry) GetIssuer() string
- func (e Entry) GetMSPID() stringdeprecated
- func (e Entry) GetMSPIdentifier() string
- func (e Entry) GetPEM() []byte
- func (e Entry) GetPublicKey() interface{}
- func (e Entry) GetSubject() string
- func (e Entry) Is(id Identity) bool
- type Id
- type Identity
- type IdentityAttrs
- type IdentityEntry
- type SubjectIssuer
Constants ¶
This section is empty.
Variables ¶
var ( // ErrMSPIdentifierNotEqual occurs when msp id did not match ErrMSPIdentifierNotEqual = errors.New(`msp identifier not equal`) ErrSubjectNotEqual = errors.New(`certificate subject not equal`) ErrIssuerNotEqual = errors.New(`certificate issuer not equal`) )
var ( ErrInvalidPEMStructure = errors.New(`invalid pem structure`) // ErrPemEncodedExpected pem format error ErrPemEncodedExpected = errors.New("expecting a PEM-encoded X509 certificate; PEM block not found") )
Functions ¶
func CertEqual ¶ added in v0.7.8
func CertEqual(cert1, cert2 SubjectIssuer) error
CertEqual checks certificate equality
func CertSubjEqual ¶ added in v0.6.4
func Certificate ¶
func Certificate(c []byte) (cert *x509.Certificate, err error)
Certificate decode and parse .pem []byte x509 certificate structure
func Equal ¶ added in v0.8.2
func Equal(identity1, identity2 IdentityAttrs) error
Equal checks identity attributes (Msp id, cert subject and cert issuer) equality
func GetDN ¶
GetDN (distinguished name) associated with a pkix.Name. NOTE: This code is almost a direct copy of the String() function in https://go-review.googlesource.com/c/go/+/67270/1/src/crypto/x509/pkix/pkix.go#26 which returns a DN as defined by RFC 2253.
func IDByCert ¶
func IDByCert(cert *x509.Certificate) string
IDByCert returns id by certificate subject and issuer
func MarshalPublicKey ¶ added in v0.10.5
func MarshalPublicKey(publicKey interface{}) []byte
func PrivateKey ¶ added in v0.6.4
func PrivateKey(keyBytes []byte) (*ecdsa.PrivateKey, error)
Types ¶
type CertIdentity ¶
type CertIdentity struct { MspID string Cert *x509.Certificate }
CertIdentity structs holds data of tx creator
func FromSerialized ¶
func FromSerialized(s protomsp.SerializedIdentity) (ci *CertIdentity, err error)
FromSerialized converts msp.SerializedIdentity struct to Identity interface{}
func FromStub ¶
func FromStub(stub shim.ChaincodeStubInterface) (*CertIdentity, error)
FromStub creates Identity interface from tx creator mspID and certificate (stub.GetCreator)
func New ¶
func New(mspID string, certPEM []byte) (ci *CertIdentity, err error)
New creates CertIdentity struct from an mspID and certificate
func (CertIdentity) Anonymous ¶ added in v0.6.4
func (ci CertIdentity) Anonymous() bool
func (CertIdentity) ExpiresAt ¶ added in v0.6.4
func (ci CertIdentity) ExpiresAt() time.Time
func (CertIdentity) GetID ¶
func (ci CertIdentity) GetID() string
GetID get id based in certificate subject and issuer
func (CertIdentity) GetIdentifier ¶ added in v0.6.4
func (ci CertIdentity) GetIdentifier() *msp.IdentityIdentifier
func (CertIdentity) GetIssuer ¶
func (ci CertIdentity) GetIssuer() string
GetIssuer returns invoker's certificate issuer
func (CertIdentity) GetMSPIdentifier ¶ added in v0.6.4
func (ci CertIdentity) GetMSPIdentifier() string
func (CertIdentity) GetOrganizationalUnits ¶ added in v0.6.4
func (ci CertIdentity) GetOrganizationalUnits() []*msp.OUIdentifier
func (CertIdentity) GetPEM ¶
func (ci CertIdentity) GetPEM() []byte
GetPEM certificate encoded to PEM
func (CertIdentity) GetPublicKey ¶
func (ci CertIdentity) GetPublicKey() interface{}
func (CertIdentity) GetPublicVersion ¶ added in v0.6.4
func (ci CertIdentity) GetPublicVersion() msp.Identity
func (CertIdentity) GetSubject ¶
func (ci CertIdentity) GetSubject() string
GetSubject returns invoker's certificate subject
func (CertIdentity) SatisfiesPrincipal ¶ added in v0.6.4
func (ci CertIdentity) SatisfiesPrincipal(principal *protomsp.MSPPrincipal) error
func (CertIdentity) Serialize ¶ added in v0.6.4
func (ci CertIdentity) Serialize() ([]byte, error)
func (CertIdentity) ToBytes ¶
func (ci CertIdentity) ToBytes() ([]byte, error)
ToBytes converts to serializedIdentity and then to json
func (CertIdentity) ToSerialized ¶
func (ci CertIdentity) ToSerialized() *protomsp.SerializedIdentity
ToSerialized converts CertIdentity to *msp.SerializedIdentity
func (CertIdentity) Validate ¶ added in v0.6.4
func (ci CertIdentity) Validate() error
type Entry ¶
type Entry struct { MSPId string Subject string Issuer string PEM []byte Cert *x509.Certificate `json:"-"` // temporary cert }
Entry structure for storing identity information string representation certificate Subject and Issuer can be used for reach query searching
func CreateEntry ¶
CreateEntry creates IdentityEntry structure from an identity interface
func EntryFromSerialized ¶
func EntryFromSerialized(s protomsp.SerializedIdentity) (g *Entry, err error)
EntryFromSerialized creates Entry from SerializedEntry
func EntryFromStub ¶
func EntryFromStub(stub shim.ChaincodeStubInterface) (g *Entry, err error)
func (Entry) GetIdentityEntry ¶
func (Entry) GetMSPIdentifier ¶ added in v0.8.2
func (Entry) GetPublicKey ¶
func (e Entry) GetPublicKey() interface{}
type Identity ¶
type Identity interface { msp.Identity // GetSubject string representation of X.509 cert subject GetSubject() string // GetIssuer string representation of X.509 cert issuer GetIssuer() string // GetPublicKey *rsa.PublicKey or *dsa.PublicKey or *ecdsa.PublicKey: GetPublicKey() interface{} GetPEM() []byte }
Identity interface for invoker (tx creator) and grants, stored in chain code state
type IdentityAttrs ¶ added in v0.8.2
type IdentityAttrs interface { SubjectIssuer GetMSPIdentifier() string }
type IdentityEntry ¶
type IdentityEntry interface {
GetIdentityEntry() Entry
}
IdentityEntry interface