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

pull in upstrea #1

Open
wants to merge 77 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
ab2f90f
Bump github.com/urfave/cli from 1.22.1 to 1.22.2
dependabot-preview[bot] Nov 22, 2019
004e21b
Merge pull request #91 from square/dependabot/go_modules/github.com/u…
mcpherrinm Nov 22, 2019
99059f9
Add option to create CA restricted to some domains
fd0 Dec 20, 2019
888ea0d
Set CRL expiration to 2 years
Jan 6, 2020
1eaeef9
Merge pull request #97 from sashabaranov/master
mcpherrinm Feb 6, 2020
f0c6e7d
Bump github.com/urfave/cli from 1.22.2 to 1.22.3
dependabot-preview[bot] Mar 9, 2020
cadabbf
Merge pull request #98 from square/dependabot/go_modules/github.com/u…
mbyczkowski Mar 9, 2020
92cd0f3
Remove vendorized dependencies in favor of Go modules
mbyczkowski Dec 20, 2019
e37bb83
Clean-up test execution
mbyczkowski Dec 20, 2019
a85247f
Merge pull request #93 from square/mbyczkowski/cleanup-tests
mbyczkowski Apr 7, 2020
bcd0252
Bump github.com/urfave/cli from 1.22.3 to 1.22.4
dependabot-preview[bot] Apr 7, 2020
c746960
Fix docker build after removal of vendored deps
mbyczkowski Apr 12, 2020
b481fd7
Merge pull request #104 from square/dependabot/go_modules/github.com/…
mbyczkowski Apr 12, 2020
faf0794
Merge pull request #106 from square/mbyczkowski/fix-docker-build
mbyczkowski Apr 14, 2020
039b484
Configure GitHub Actions
mbyczkowski Apr 19, 2020
5d5de6c
Merge pull request #107 from square/mbyczkowski/test-gh-actions
mbyczkowski Apr 20, 2020
966f653
Fix issues surfaced by running `golangci-lint run`
mbyczkowski Apr 20, 2020
54b5467
Enforce linter errors
mbyczkowski Apr 20, 2020
ec28c5a
Merge pull request #108 from square/mbyczkowski/linter-fixes
mbyczkowski Apr 23, 2020
186cfda
Merge pull request #94 from fd0/add-permitted-domain
mcpherrinm May 1, 2020
23ea083
update to generated binaries information
mrtrkmn May 5, 2020
642b323
update to readme & .gitignore
mrtrkmn May 6, 2020
7cda9d4
Merge pull request #109 from mrturkmen06/patch-1
mbyczkowski May 7, 2020
20aeb70
Bump github.com/urfave/cli from 1.22.4 to 1.22.5
dependabot-preview[bot] Nov 3, 2020
6b8b03f
Merge pull request #114 from square/dependabot/go_modules/github.com/…
mbyczkowski Nov 6, 2020
6243d8b
Fix NotBefore calculation on new certificates
adregner Nov 7, 2020
14dbcb0
Merge pull request #115 from adregner/fix_minus_10min
alokmenghrajani Nov 9, 2020
9496329
Upgrade to GitHub-native Dependabot
dependabot-preview[bot] Apr 28, 2021
1768704
Merge pull request #118 from square/dependabot/add-v2-config-file
mbyczkowski May 10, 2021
378329b
Use CA signing key instead of the subject signing key in the revocati…
jdtw Nov 17, 2021
9864e7f
Move to the correct Go lint action
jdtw Nov 17, 2021
3ff5d9c
Merge pull request #122 from square/jwood/fix-1.17-tests
jdtw Nov 17, 2021
14f1e5d
Merge pull request #123 from square/jwood/fix-linter
jdtw Nov 17, 2021
b8e7bd9
Exclude the deprecated PEM functions from CI lints (#125)
jdtw Nov 17, 2021
21a080e
Move to Go 1.17 (#126)
jdtw Nov 17, 2021
5fd1b5e
Remove deprecated Travis CI config (#127)
jdtw Nov 17, 2021
6b3ab22
Add support for ECC to the pkix package (#130)
jdtw Dec 2, 2021
95bea3d
Add flags to certstrap to support ECDSA and Ed25519 (#128)
jdtw Dec 2, 2021
fda01db
Add support for SPIFFE cert requests (#131)
jdtw Dec 2, 2021
31db230
Add CODEOWNERS
mbyczkowski Feb 8, 2022
7f17e94
Fix file permission checking in the depot package (#141)
jdtw Feb 8, 2022
ccb7865
Merge pull request #142 from square/mbyczkowski-patch-1
mbyczkowski Feb 8, 2022
5f47dce
Bump go.step.sm/crypto from 0.13.0 to 0.15.2
dependabot[bot] Mar 7, 2022
2a55ac3
Merge pull request #145 from square/dependabot/go_modules/go.step.sm/…
isemaya-square Mar 8, 2022
140d075
updated go version to 1.16
isemaya-square Apr 15, 2022
6dbe487
Bump github.com/urfave/cli from 1.22.5 to 1.22.9
dependabot[bot] May 5, 2022
03d7ee0
Merge pull request #154 from square/dependabot/go_modules/github.com/…
isemaya-square May 6, 2022
8ec8597
created separate perms for windows so that windows users will no long…
isemaya-square May 16, 2022
6ca2185
Update go.yml
isemaya-square May 16, 2022
bdab43c
Update go.yml
isemaya-square May 16, 2022
f5b43fc
created test_tags and test_tags_windows since 600 permissions are not…
isemaya-square May 16, 2022
4b5cbd1
Merge pull request #155 from square/isemaya/certstrap-special-windows…
isemaya-square May 17, 2022
315dc34
Bump go.step.sm/crypto from 0.15.2 to 0.16.2
dependabot[bot] May 18, 2022
ca59001
Merge pull request #157 from square/dependabot/go_modules/go.step.sm/…
isemaya-square Jun 13, 2022
e196b0e
Expand on permissions error message. (#160)
mcdee Jun 21, 2022
df02414
Fix docker file (#161)
jdtw Jun 21, 2022
825fe42
Add support for setting `pathlen` on CA certificates and intermediate…
socheatsok78 Jun 24, 2022
760fa79
Merge pull request #151 from square/isemaya/certstrap-bump-go-version
mbyczkowski Jun 29, 2022
4f638ae
Move to Go 1.18 (#162)
jdtw Jul 1, 2022
1377eab
Fix typo in release workflow (#163)
jdtw Jul 1, 2022
88e21eb
check for passphrase in saveRevokedCertificates
isemaya-square Jul 14, 2022
edee3ec
added revoke command to workflow test
isemaya-square Jul 14, 2022
992908f
added passphrase as a flag to revoke command so that we can run workf…
isemaya-square Jul 14, 2022
4297ef4
Bump go.step.sm/crypto from 0.16.2 to 0.17.0
dependabot[bot] Jul 15, 2022
98b4087
removed debug print statements
isemaya-square Jul 21, 2022
ad1ccbf
Merge pull request #165 from square/isemaya/certstrap-fix-revoke-key-…
isemaya-square Jul 21, 2022
9b5cab7
Merge pull request #166 from square/dependabot/go_modules/go.step.sm/…
mbyczkowski Jul 22, 2022
cfa51ec
update cism to cryptographic-identity
violetd12 Feb 10, 2023
3becfc1
Merge pull request #187 from square/violet/update_cism_to_cryptograph…
violetd12 Feb 14, 2023
5b7187e
Bump go.step.sm/crypto from 0.17.0 to 0.25.1
dependabot[bot] Mar 1, 2023
72bbf89
Merge pull request #188 from square/dependabot/go_modules/go.step.sm/…
mbyczkowski Mar 2, 2023
f542be8
Bump github.com/urfave/cli from 1.22.9 to 1.22.12
dependabot[bot] Mar 2, 2023
32fba74
Merge pull request #183 from square/dependabot/go_modules/github.com/…
mbyczkowski Mar 2, 2023
86891c1
release for arm64
gflex Mar 27, 2023
a927d66
Bump github.com/urfave/cli from 1.22.12 to 1.22.13
dependabot[bot] May 1, 2023
888b72f
Merge pull request #199 from square/dependabot/go_modules/github.com/…
mbyczkowski May 12, 2023
762223e
Merge pull request #194 from gflex/arm64
mbyczkowski May 12, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: gomod
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
77 changes: 77 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: CI

on: [push, pull_request]

jobs:

build:
name: Build
runs-on: ubuntu-latest
steps:

- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.18
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Get dependencies
run: go mod download

- name: Run tests
run: GODEBUG=x509sha1=1 go test -v ./...

- name: Build binaries
run: go build -o . ./...

- name: Run integration tests
run: GODEBUG=x509sha1=1 go test -v -tags=integration ./...

lint:
name: Lint
runs-on: ubuntu-latest
steps:

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Run golangci-lint
uses: golangci/golangci-lint-action@v2

with:
# Exclude deprecated PEM functions from the linter until
# https://github.com/square/certstrap/issues/124 is resolved
args: --exclude '(De|En)cryptPEMBlock'

build-windows:
name: Build Windows
runs-on: windows-latest
steps:

- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.17
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Get dependencies
run: go mod download

- name: Run tests
run: |
set GODEBUG=x509sha1=1
go test -v ./...

- name: Build binaries
run: go build -o . ./...

- name: Run integration tests
run: |
set GODEBUG=x509sha1=1
go test -v -tags=integration ./...
84 changes: 84 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
name: Release

on:
push:
tags: [ "*" ]

jobs:
build:
name: Build
strategy:
matrix:
version: [1.18.x]
target:
- { os: 'darwin', platform: 'macos-latest', arch: 'amd64' }
- { os: 'darwin', platform: 'macos-latest', arch: 'arm64' }
- { os: 'linux', platform: 'ubuntu-latest', arch: 'amd64' }
- { os: 'linux', platform: 'ubuntu-latest', arch: 'arm64' }
- { os: 'windows', platform: 'windows-latest', arch: 'amd64' }
runs-on: ${{ matrix.target.platform }}
steps:
- name: Set up toolchain
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.version }}
id: go
- name: Check out code
uses: actions/checkout@v2
- name: Build binary
run: go build -o certstrap .
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: certstrap-${{ matrix.target.os }}-${{ matrix.target.arch }}
path: certstrap

release:
name: Create release
runs-on: ubuntu-latest
needs: [ build ]
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- uses: actions/checkout@v2
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: "Release Build (Draft)"
body: "Release Build (from ${{ github.ref }}/${{ github.sha }})"
draft: true
prerelease: true

add-assets:
name: Add assets
runs-on: ubuntu-latest
needs: [ build, release ]
strategy:
matrix:
target:
- { os: 'darwin', arch: 'amd64' }
- { os: 'darwin', arch: 'arm64' }
- { os: 'linux', arch: 'amd64' }
- { os: 'linux', arch: 'arm64' }
- { os: 'windows', arch: 'amd64' }
steps:
- uses: actions/checkout@v2
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: certstrap-${{ matrix.target.os }}-${{ matrix.target.arch }}
path: dist
- name: Upload artifact to release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: ./dist/certstrap
asset_name: certstrap-${{ matrix.target.os }}-${{ matrix.target.arch }}
asset_content_type: application/octet-stream
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@ gopath
bin
out
certstrap
# Intellij Idea Generates following file
# Nice to have in .gitignore
.idea/
# .DS_Store file sometimes generated by Mac computers
.DS_Store
21 changes: 0 additions & 21 deletions .travis.yml

This file was deleted.

1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @square/cryptographic-identity
18 changes: 12 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,25 @@
# To run certstrap from the image (for example):
# docker run --rm squareup/certstrap --version

FROM golang:1.11.2-alpine as build
FROM golang:1.18-alpine as build

MAINTAINER Cedric Staub "[email protected]"
WORKDIR /app

COPY go.mod .
COPY go.sum .

# Download dependencies
RUN go mod download

# Copy source
COPY . /go/src/github.com/square/certstrap
COPY . .

# Build
RUN go build -o /usr/bin/certstrap github.com/square/certstrap
RUN CGO_ENABLED=0 go build -buildvcs=false -o /usr/bin/certstrap github.com/square/certstrap

# Create a multi-stage build with the binary
FROM alpine
FROM gcr.io/distroless/static

COPY --from=build /usr/bin/certstrap /usr/bin/certstrap

ENTRYPOINT ["/usr/bin/certstrap"]
ENTRYPOINT ["/usr/bin/certstrap"]
30 changes: 22 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# certstrap
[![godoc](http://img.shields.io/badge/godoc-certstrap-blue.svg?style=flat)](https://godoc.org/github.com/square/certstrap)
[![build](https://img.shields.io/travis/square/certstrap.svg?style=flat)](https://travis-ci.org/square/certstrap) [![license](http://img.shields.io/badge/license-apache_2.0-red.svg?style=flat)](https://raw.githubusercontent.com/square/certstrap/master/LICENSE)
[![CI](https://github.com/square/certstrap/actions/workflows/go.yml/badge.svg)](https://github.com/square/certstrap/actions/workflows/go.yml)
[![license](http://img.shields.io/badge/license-apache_2.0-red.svg?style=flat)](https://raw.githubusercontent.com/square/certstrap/master/LICENSE)

A simple certificate manager written in Go, to bootstrap your own certificate authority and public key infrastructure. Adapted from etcd-ca.

Expand All @@ -24,20 +25,20 @@ certstrap can init multiple certificate authorities to sign certificates with.

### Building

certstrap must be built with Go 1.13+. You can build certstrap from source:
certstrap must be built with Go 1.18+. You can build certstrap from source:

```
$ git clone https://github.com/square/certstrap
$ cd certstrap
$ ./build
$ go build
```

This will generate a binary called `./bin/certstrap`
This will generate a binary called `certstrap` under project root folder.

### Initialize a new certificate authority:

```
$ ./bin/certstrap init --common-name "CertAuth"
$ ./certstrap init --common-name "CertAuth"
Created out/CertAuth.key
Created out/CertAuth.crt
Created out/CertAuth.crl
Expand All @@ -51,7 +52,7 @@ though you can use a pre-existing private PEM key with the `-key` flag.
If the CN contains spaces, certstrap will change them to underscores in the filename for easier use. The spaces will be preserved inside the fields of the generated files:

```
$ ./bin/certstrap init --common-name "Cert Auth"
$ ./certstrap init --common-name "Cert Auth"
Created out/Cert_Auth.key
Created out/Cert_Auth.crt
Created out/Cert_Auth.crl
Expand All @@ -60,7 +61,7 @@ Created out/Cert_Auth.crl
### Request a certificate, including keypair:

```
$ ./bin/certstrap request-cert --common-name Alice
$ ./certstrap request-cert --common-name Alice
Created out/Alice.key
Created out/Alice.csr
```
Expand All @@ -75,7 +76,7 @@ PEM key with the `-key` flag
### Sign certificate request of host and generate the certificate:

```
$ ./bin/certstrap sign Alice --CA CertAuth
$ ./certstrap sign Alice --CA CertAuth
Created out/Alice.crt from out/Alice.csr signed by out/CertAuth.key
```

Expand All @@ -86,6 +87,19 @@ $ openssl pkcs12 -export -out outputCert.p12 -inkey inputKey.key -in inputCert.c
```
`inputKey.key` and `inputCert.crt` make up the leaf private key and certificate pair of your choosing (generated by a `sign` command), with `CA.crt` being the certificate authority certificate that was used to sign it. The output PKCS12 file is `outputCert.p12`

### Key Algorithms:
Certstrap supports curves P-224, P-256, P-384, P-521, and Ed25519. Curve names can be specified by name as part of the `init` and `request_cert` commands:

```
$ ./certstrap init --common-name CertAuth --curve P-256
Created out/CertAuth.key
Created out/CertAuth.crt
Created out/CertAuth.crl

$ ./certstrap request-cert --common-name Alice --curve P-256
Created out/Alice.key
Created out/Alice.csr
```

### Retrieving Files

Expand Down
23 changes: 0 additions & 23 deletions build

This file was deleted.

6 changes: 2 additions & 4 deletions certstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ import (
"github.com/urfave/cli"
)

// release is overriden by the build script using -X argument that is passed to the Go linker.
var release = "(version not set)"
var release = "1.3.0"

func main() {
app := cli.NewApp()
Expand All @@ -50,8 +49,7 @@ func main() {
cmd.NewRevokeCommand(),
}
app.Before = func(c *cli.Context) error {
cmd.InitDepot(c.String("depot-path"))
return nil
return cmd.InitDepot(c.String("depot-path"))
}

if err := app.Run(os.Args); err != nil {
Expand Down
Loading