Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add back support for building with CGO_ENABLED=0 #293

Merged
merged 1 commit into from
Dec 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
}