Skip to content

Commit

Permalink
[FABG-1000] Update pinning for fabric-ca (#104)
Browse files Browse the repository at this point in the history
Updates to fabric-ca:3a1323d

Signed-off-by: Troy Ronda <troy@troyronda.com>
  • Loading branch information
troyronda committed Jul 21, 2020
1 parent a336df6 commit c97fe34
Show file tree
Hide file tree
Showing 31 changed files with 229 additions and 75 deletions.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -71,7 +71,7 @@ BASE_GO_VERSION = "1.14"

# Upstream fabric patching (overridable)
THIRDPARTY_FABRIC_CA_BRANCH ?= master
THIRDPARTY_FABRIC_CA_COMMIT ?= 02fe02b0a6f224aac8ac6fd813cecc590ec2a024
THIRDPARTY_FABRIC_CA_COMMIT ?= 3a1323dafce1ecbe79444fc8701596e34f18d3e0
THIRDPARTY_FABRIC_BRANCH ?= master
THIRDPARTY_FABRIC_COMMIT ?= v2.2.0

Expand Down
10 changes: 3 additions & 7 deletions go.mod
Expand Up @@ -8,20 +8,17 @@ require (
github.com/Knetic/govaluate v3.0.0+incompatible
github.com/VividCortex/gohistogram v1.0.0 // indirect
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 // indirect
github.com/cloudflare/cfssl v0.0.0-20180223231731-4e2dcbde5004
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/cloudflare/cfssl v1.4.1
github.com/go-kit/kit v0.8.0
github.com/go-logfmt/logfmt v0.4.0 // indirect
github.com/go-stack/stack v1.8.0 // indirect
github.com/gogo/protobuf v1.1.1
github.com/golang/mock v1.2.0
github.com/golang/protobuf v1.3.3
github.com/google/certificate-transparency-go v0.0.0-20180222191210-5ab67e519c93 // indirect
github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce // indirect
github.com/hyperledger/fabric-config v0.0.6
github.com/hyperledger/fabric-lib-go v1.0.0
github.com/hyperledger/fabric-protos-go v0.0.0-20200424173316-dd554ba3746e
github.com/kr/pretty v0.1.0 // indirect
github.com/magiconair/properties v1.7.6 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/miekg/pkcs11 v0.0.0-20190329070431-55f3fac3af27
Expand All @@ -38,11 +35,10 @@ require (
github.com/spf13/pflag v1.0.1 // indirect
github.com/spf13/viper v1.0.2
github.com/stretchr/testify v1.3.0
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
golang.org/x/net v0.0.0-20190311183353-d8887717615a
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3
google.golang.org/genproto v0.0.0-20190327125643-d831d65fe17d // indirect
google.golang.org/grpc v1.23.0
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
gopkg.in/yaml.v2 v2.2.4
)

Expand Down
60 changes: 56 additions & 4 deletions go.sum

Large diffs are not rendered by default.

21 changes: 10 additions & 11 deletions internal/github.com/hyperledger/fabric-ca/lib/client.go
Expand Up @@ -28,14 +28,13 @@ import (

cfsslapi "github.com/cloudflare/cfssl/api"
"github.com/cloudflare/cfssl/csr"
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/api"
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/lib/client/credential"
x509cred "github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/lib/client/credential/x509"
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/lib/common"
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/lib/streamer"
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/lib/tls"
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/sdkinternal/pkg/api"
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/sdkinternal/pkg/util"
log "github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/sdkpatch/logbridge"
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/util"
"github.com/mitchellh/mapstructure"
"github.com/pkg/errors"
)
Expand Down Expand Up @@ -171,7 +170,7 @@ func (c *Client) GetCAInfo(req *api.GetCAInfoRequest) (*GetCAInfoResponse, error
if err != nil {
return nil, err
}
netSI := &common.CAInfoResponseNet{}
netSI := &api.CAInfoResponseNet{}
err = c.SendReq(cainforeq, netSI)
if err != nil {
return nil, err
Expand All @@ -197,7 +196,7 @@ func (c *Client) GenCSR(req *api.CSRInfo, id string) ([]byte, core.Key, error) {
cr.CN = id

if (cr.KeyRequest == nil) || (cr.KeyRequest.Size() == 0 && cr.KeyRequest.Algo() == "") {
cr.KeyRequest = newCfsslBasicKeyRequest(api.NewBasicKeyRequest())
cr.KeyRequest = newCfsslKeyRequest(api.NewKeyRequest())
}

key, cspSigner, err := util.BCCSPKeyRequestGenerate(cr, c.csp)
Expand Down Expand Up @@ -232,7 +231,7 @@ func (c *Client) Enroll(req *api.EnrollmentRequest) (*EnrollmentResponse, error)
}

// Convert from network to local CA information
func (c *Client) net2LocalCAInfo(net *common.CAInfoResponseNet, local *GetCAInfoResponse) error {
func (c *Client) net2LocalCAInfo(net *api.CAInfoResponseNet, local *GetCAInfoResponse) error {
caChain, err := util.B64Decode(net.CAChain)
if err != nil {
return errors.WithMessage(err, "Failed to decode CA chain")
Expand Down Expand Up @@ -287,7 +286,7 @@ func (c *Client) handleX509Enroll(req *api.EnrollmentRequest) (*EnrollmentRespon
return nil, err
}
post.SetBasicAuth(req.Name, req.Secret)
var result common.EnrollmentResponseNet
var result api.EnrollmentResponseNet
err = c.SendReq(post, &result)
if err != nil {
return nil, err
Expand All @@ -312,7 +311,7 @@ func (c *Client) handleIdemixEnroll(req *api.EnrollmentRequest) (*EnrollmentResp
// @param result The result from server
// @param id Name of identity being enrolled or reenrolled
// @param key The private key which was used to sign the request
func (c *Client) newEnrollmentResponse(result *common.EnrollmentResponseNet, id string, key core.Key) (*EnrollmentResponse, error) {
func (c *Client) newEnrollmentResponse(result *api.EnrollmentResponseNet, id string, key core.Key) (*EnrollmentResponse, error) {
log.Debugf("newEnrollmentResponse %s", id)
certByte, err := util.B64Decode(result.Cert)
if err != nil {
Expand Down Expand Up @@ -355,7 +354,7 @@ func (c *Client) newCertificateRequest(req *api.CSRInfo) *csr.CertificateRequest
}
}
if req != nil && req.KeyRequest != nil {
cr.KeyRequest = newCfsslBasicKeyRequest(req.KeyRequest)
cr.KeyRequest = newCfsslKeyRequest(req.KeyRequest)
}
if req != nil {
cr.CA = req.CA
Expand Down Expand Up @@ -573,8 +572,8 @@ func (c *Client) checkX509Enrollment() error {
return errors.New("X509 enrollment information does not exist")
}

func newCfsslBasicKeyRequest(bkr *api.BasicKeyRequest) *csr.BasicKeyRequest {
return &csr.BasicKeyRequest{A: bkr.Algo, S: bkr.Size}
func newCfsslKeyRequest(bkr *api.KeyRequest) *csr.KeyRequest {
return &csr.KeyRequest{A: bkr.Algo, S: bkr.Size}
}

// NormalizeURL normalizes a URL (from cfssl)
Expand Down
Expand Up @@ -13,7 +13,7 @@ package credential
import (
"net/http"

"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/api"
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/sdkinternal/pkg/api"
)

// Credential represents an credential of an identity
Expand Down
Expand Up @@ -19,9 +19,9 @@ import (
factory "github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/sdkpatch/cryptosuitebridge"
log "github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/sdkpatch/logbridge"

"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/api"
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/lib/client/credential"
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/util"
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/sdkinternal/pkg/api"
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/sdkinternal/pkg/util"
"github.com/pkg/errors"
)

Expand Down
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/hyperledger/fabric-sdk-go/pkg/common/providers/core"

"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/lib/attrmgr"
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/util"
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/sdkinternal/pkg/util"
"github.com/pkg/errors"
)

Expand Down
Expand Up @@ -23,8 +23,8 @@ package lib
import (
"github.com/hyperledger/fabric-sdk-go/pkg/common/providers/core"

"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/api"
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/lib/tls"
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/sdkinternal/pkg/api"
)

// ClientConfig is the fabric-ca client's config
Expand Down
7 changes: 3 additions & 4 deletions internal/github.com/hyperledger/fabric-ca/lib/identity.go
Expand Up @@ -16,12 +16,11 @@ import (
"net/http"
"strconv"

"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/api"
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/lib/client/credential"
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/lib/client/credential/x509"
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/lib/common"
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/sdkinternal/pkg/api"
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/sdkinternal/pkg/util"
log "github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/sdkpatch/logbridge"
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/util"
"github.com/pkg/errors"
)

Expand Down Expand Up @@ -112,7 +111,7 @@ func (i *Identity) Reenroll(req *api.ReenrollmentRequest) (*EnrollmentResponse,
if err != nil {
return nil, err
}
var result common.EnrollmentResponseNet
var result api.EnrollmentResponseNet
err = i.Post("reenroll", body, &result, nil)
if err != nil {
return nil, err
Expand Down
Expand Up @@ -11,7 +11,7 @@ Please review third_party pinning scripts and patches for more details.
package lib

import (
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/api"
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/sdkinternal/pkg/api"
)

type revocationResponseNet struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/github.com/hyperledger/fabric-ca/lib/tls/tls.go
Expand Up @@ -27,9 +27,9 @@ import (

"github.com/hyperledger/fabric-sdk-go/pkg/common/providers/core"

"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/sdkinternal/pkg/util"
factory "github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/sdkpatch/cryptosuitebridge"
log "github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/sdkpatch/logbridge"
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/util"
"github.com/pkg/errors"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/github.com/hyperledger/fabric-ca/lib/util.go
Expand Up @@ -17,7 +17,7 @@ import (
"encoding/pem"
"net/http"

"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/util"
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/sdkinternal/pkg/util"
"github.com/pkg/errors"
)

Expand Down
Expand Up @@ -14,7 +14,7 @@ import (
"time"

"github.com/cloudflare/cfssl/csr"
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/util"
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/sdkinternal/pkg/util"
)

// RegistrationRequest for a new identity
Expand Down Expand Up @@ -275,12 +275,12 @@ type AffiliationInfo struct {

// CSRInfo is Certificate Signing Request (CSR) Information
type CSRInfo struct {
CN string `json:"CN"`
Names []csr.Name `json:"names,omitempty"`
Hosts []string `json:"hosts,omitempty"`
KeyRequest *BasicKeyRequest `json:"key,omitempty"`
CA *csr.CAConfig `json:"ca,omitempty" hide:"true"`
SerialNumber string `json:"serial_number,omitempty"`
CN string `json:"CN"`
Names []csr.Name `json:"names,omitempty"`
Hosts []string `json:"hosts,omitempty"`
KeyRequest *KeyRequest `json:"key,omitempty"`
CA *csr.CAConfig `json:"ca,omitempty" hide:"true"`
SerialNumber string `json:"serial_number,omitempty"`
}

// GetCertificatesRequest represents the request to get certificates from the server
Expand Down Expand Up @@ -310,8 +310,8 @@ type TimeRange struct {
EndTime string
}

// BasicKeyRequest encapsulates size and algorithm for the key to be generated
type BasicKeyRequest struct {
// KeyRequest encapsulates size and algorithm for the key to be generated
type KeyRequest struct {
Algo string `json:"algo" yaml:"algo" help:"Specify key algorithm"`
Size int `json:"size" yaml:"size" help:"Specify key size"`
}
Expand Down Expand Up @@ -350,9 +350,9 @@ func (ar *AttributeRequest) IsRequired() bool {
return !ar.Optional
}

// NewBasicKeyRequest returns the BasicKeyRequest object that is constructed
// from the object returned by the csr.NewBasicKeyRequest() function
func NewBasicKeyRequest() *BasicKeyRequest {
bkr := csr.NewBasicKeyRequest()
return &BasicKeyRequest{Algo: bkr.A, Size: bkr.S}
// NewKeyRequest returns the KeyRequest object that is constructed
// from the object returned by the csr.NewKeyRequest() function
func NewKeyRequest() *KeyRequest {
bkr := csr.NewKeyRequest()
return &KeyRequest{Algo: bkr.A, Size: bkr.S}
}
Expand Up @@ -8,7 +8,7 @@ Notice: This file has been modified for Hyperledger Fabric SDK Go usage.
Please review third_party pinning scripts and patches for more details.
*/

package common
package api

const (
// IdemixTokenVersion1 represents version 1 of the authorization token created using Idemix credential
Expand Down
Expand Up @@ -42,7 +42,7 @@ import (

// getBCCSPKeyOpts generates a key as specified in the request.
// This supports ECDSA.
func getBCCSPKeyOpts(kr csr.KeyRequest, ephemeral bool) (opts core.KeyGenOpts, err error) {
func getBCCSPKeyOpts(kr *csr.KeyRequest, ephemeral bool) (opts core.KeyGenOpts, err error) {
if kr == nil {
return factory.GetECDSAKeyGenOpts(ephemeral), nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/msp/example_test.go
Expand Up @@ -9,7 +9,7 @@ import (
"fmt"

"github.com/cloudflare/cfssl/log"
fabricCaUtil "github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/util"
fabricCaUtil "github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/sdkinternal/pkg/util"
"github.com/hyperledger/fabric-sdk-go/pkg/common/logging"
"github.com/hyperledger/fabric-sdk-go/pkg/common/providers/context"
"github.com/hyperledger/fabric-sdk-go/pkg/common/providers/msp"
Expand Down
2 changes: 1 addition & 1 deletion pkg/core/config/cryptoutil/cryptoutils_test.go
Expand Up @@ -9,7 +9,7 @@ package cryptoutil
import (
"testing"

fabricCaUtil "github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/util"
fabricCaUtil "github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/sdkinternal/pkg/util"
"github.com/hyperledger/fabric-sdk-go/pkg/core/cryptosuite"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/gateway/gateway.go
Expand Up @@ -21,7 +21,7 @@ import (
"strings"
"time"

fabricCaUtil "github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/util"
fabricCaUtil "github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/sdkinternal/pkg/util"
"github.com/hyperledger/fabric-sdk-go/pkg/common/providers/context"
"github.com/hyperledger/fabric-sdk-go/pkg/common/providers/core"
"github.com/hyperledger/fabric-sdk-go/pkg/common/providers/fab"
Expand Down
2 changes: 1 addition & 1 deletion pkg/msp/enrollment_test.go
Expand Up @@ -13,7 +13,7 @@ import (
"testing"

"github.com/golang/mock/gomock"
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/util"
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/sdkinternal/pkg/util"
"github.com/hyperledger/fabric-sdk-go/pkg/common/providers/core"
providersFab "github.com/hyperledger/fabric-sdk-go/pkg/common/providers/fab"
"github.com/hyperledger/fabric-sdk-go/pkg/common/providers/msp"
Expand Down
2 changes: 1 addition & 1 deletion pkg/msp/fabcaadapter.go
Expand Up @@ -11,10 +11,10 @@ import (

"encoding/json"

caapi "github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/api"
calib "github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/lib"
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/lib/client/credential"
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/lib/client/credential/x509"
caapi "github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/sdkinternal/pkg/api"
"github.com/hyperledger/fabric-sdk-go/pkg/common/providers/core"
"github.com/hyperledger/fabric-sdk-go/pkg/common/providers/msp"
"github.com/hyperledger/fabric-sdk-go/pkg/core/config/endpoint"
Expand Down
2 changes: 1 addition & 1 deletion pkg/msp/getsigid.go
Expand Up @@ -10,7 +10,7 @@ import (
"fmt"
"strings"

fabricCaUtil "github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/util"
fabricCaUtil "github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/sdkinternal/pkg/util"
"github.com/hyperledger/fabric-sdk-go/pkg/common/providers/core"
"github.com/hyperledger/fabric-sdk-go/pkg/common/providers/msp"
"github.com/hyperledger/fabric-sdk-go/pkg/core/config/cryptoutil"
Expand Down
2 changes: 1 addition & 1 deletion pkg/msp/getsigid_test.go
Expand Up @@ -14,7 +14,7 @@ import (
"strings"
"testing"

fabricCaUtil "github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/util"
fabricCaUtil "github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/sdkinternal/pkg/util"
"github.com/hyperledger/fabric-sdk-go/pkg/common/providers/core"
providersFab "github.com/hyperledger/fabric-sdk-go/pkg/common/providers/fab"
"github.com/hyperledger/fabric-sdk-go/pkg/common/providers/msp"
Expand Down
4 changes: 2 additions & 2 deletions pkg/msp/test/mockmsp/mockfabriccaserver.go
Expand Up @@ -12,9 +12,9 @@ import (
"time"

cfsslapi "github.com/cloudflare/cfssl/api"
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/api"
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/lib"
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/util"
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/sdkinternal/pkg/api"
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/sdkinternal/pkg/util"
"github.com/hyperledger/fabric-sdk-go/pkg/common/logging"
"github.com/hyperledger/fabric-sdk-go/pkg/common/providers/core"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/msp/user_test.go
Expand Up @@ -11,7 +11,7 @@ import (
"path/filepath"
"testing"

"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/util"
"github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/sdkinternal/pkg/util"
"github.com/hyperledger/fabric-sdk-go/pkg/common/providers/core"
"github.com/hyperledger/fabric-sdk-go/pkg/common/providers/msp"
"github.com/hyperledger/fabric-sdk-go/pkg/core/config"
Expand Down

0 comments on commit c97fe34

Please sign in to comment.