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

Compatibility with paultag version #49

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
22 changes: 22 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM debian:buster AS build

RUN apt-get update -y && \
apt-get install -y golang

WORKDIR /build

COPY . .

RUN go build

FROM debian:buster

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

RUN apt-get update -y && \
apt-get install --no-install-recommends -y \
curl ca-certificates openssl

WORKDIR /test
COPY tests.sh .
RUN ./tests.sh
9 changes: 9 additions & 0 deletions Dockerfile.paultag
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM debian:buster

RUN apt-get update -y && \
apt-get install --no-install-recommends -y \
minica curl ca-certificates openssl

WORKDIR /test
COPY tests.sh .
RUN ./tests.sh
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,10 @@ go build
# generate and sign an end-entity key and cert, storing them in ./foo.com/
$ minica --domains foo.com
```

For compatibility with another (unaffiliated) tool of the same name, domains
can also be specified as final arguments:

```
minica foo.com
```
8 changes: 2 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,15 +313,11 @@ will not overwrite existing keys or certificates.
flag.PrintDefaults()
}
flag.Parse()
if *domains == "" && *ipAddresses == "" {
if flag.NArg() == 0 && *domains == "" && *ipAddresses == "" {
flag.Usage()
os.Exit(1)
}
if len(flag.Args()) > 0 {
fmt.Printf("Extra arguments: %s (maybe there are spaces in your domain list?)\n", flag.Args())
os.Exit(1)
}
domainSlice := split(*domains)
domainSlice := append(split(*domains), (flag.Args())...)
domainRe := regexp.MustCompile("^[A-Za-z0-9.*-]+$")
for _, d := range domainSlice {
if !domainRe.MatchString(d) {
Expand Down
44 changes: 44 additions & 0 deletions tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

set -e
echo "world" > hello

minica localhost

set +e
# FIXME: jsha/minica puts the keypair in a directory, copy those out for compatibility
# so the same tests work against either version.
cp localhost/cert.pem localhost.crt
cp localhost/key.pem localhost.key
cp minica.pem cacert.crt
set -e

openssl s_server -cert localhost.crt -key localhost.key -accept 8080 -WWW &
set +e

curl https://localhost:8080/hello
if (( $? != 60 )); then
exit "Expected request to server with untrusted CA to fail."
fi

set -e
cp cacert.crt /usr/share/ca-certificates/
echo "cacert.crt" >> /etc/ca-certificates.conf
update-ca-certificates
set +e

curl https://localhost:8080/hello
if (( $? != 0 )); then
exit "Expected request to server with trusted CA to succeed."
fi

# FIXME: -ca-key-size and -key-size are paultag/minica-only right now, but could be ported.
# set -e
# minica -ca-key-size 4096 -key-size 4096 127.0.0.1
# openssl s_server -cert 127.0.0.1.crt -key 127.0.0.1.key -accept 8081 -WWW &
# set +e

# curl https://127.0.0.1:8081/hello
# if (( $? != 0 )); then
# exit "Expected request to server with trusted CA to succeed."
# fi