Skip to content

Commit

Permalink
Add back support for building with CGO_ENABLED=0 (#293)
Browse files Browse the repository at this point in the history
Signed-off-by: Ville Aikas <vaikas@chainguard.dev>
  • Loading branch information
vaikas committed Dec 21, 2021
1 parent ff30458 commit 2bd184c
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 2 deletions.
41 changes: 41 additions & 0 deletions cmd/app/createcanocgo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//go:build !cgo
// +build !cgo

// Copyright 2021 The Sigstore Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

package app

import (
"github.com/sigstore/fulcio/pkg/log"
"github.com/spf13/cobra"
)

// Just a placeholder for erroring with a meaningful message if the
// binary has been built with GCO_ENABLED=0 tags.
func newCreateCACmd() *cobra.Command {
return &cobra.Command{
Use: "createca",
Short: "Create a root CA in a pkcs11 device (**not supported in this binary**)",
Long: `Create an x509 root CA within a pkcs11 device using values
such as organization, country etc. This can then be used as the root
certificate authority for an instance of sigstore fulcio`,
Run: runCreateCACmdPlaceholder,
}
}

func runCreateCACmdPlaceholder(cmd *cobra.Command, args []string) {
log.Logger.Fatal("Binary has been built with CGO_ENABLED=0, createca is not supported")
}
10 changes: 8 additions & 2 deletions pkg/ca/x509ca/x509canocgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,14 @@ import (
"errors"
)

type Params struct {
ConfigPath string
RootID string
CAPath *string
}

// NewX509CA is a placeholder for erroring with a meaningful message if the
// binary has been built with purego tags.
func NewX509CA() (*X509CA, error) {
// binary has been built with CGO_ENABLED=0 tags.
func NewX509CA(params Params) (*X509CA, error) {
return nil, errors.New("binary has been built with no cgo support, PKCS11 not supported")
}

0 comments on commit 2bd184c

Please sign in to comment.