Skip to content
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
dist
tests
testdata
manpages

# ---> Go
# If you prefer the allow list template instead of the deny list, see community template:
Expand Down
45 changes: 38 additions & 7 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ before:
- sh -c 'go run . completion bash > completions/https-wrench.bash'
- sh -c 'go run . completion zsh > completions/https-wrench.zsh'
- sh -c 'go run . completion fish > completions/https-wrench.fish'
# - rm -rf manpages
# - mkdir manpages
# - sh -c 'go run . man | gzip -c > manpages/https-wrench.1.gz'
- rm -rf manpages
- mkdir manpages
- sh -c 'go run . man --dest-dir manpages'
- sh -c 'gzip manpages/*'

builds:
- env:
Expand All @@ -48,7 +49,7 @@ archives:
- README.md
- LICENSE
- completions/*
# - man/*
- manpages/*

nfpms:
- maintainer: Zeno Belli <xeno@os76.xyz>
Expand All @@ -62,12 +63,34 @@ nfpms:
contents:
- src: completions/https-wrench.bash
dst: /etc/bash_completion.d/https-wrench

- src: completions/https-wrench.fish
dst: /usr/share/fish/vendor_completions.d/https-wrench.fish

- src: completions/https-wrench.zsh
dst: /usr/share/zsh/site-functions/_https-wrench
# - src: ./manpages/https-wrench.1.gz
# dst: /usr/share/man/man1/https-.1.gz

- src: manpages/https-wrench.1.gz
dst: /usr/share/man/man1/https-wrench.1.gz

- src: manpages/https-wrench-requests.1.gz
dst: /usr/share/man/man1/https-wrench-requests.1.gz

- src: manpages/https-wrench-certinfo.1.gz
dst: /usr/share/man/man1/https-wrench-certinfo.1.gz

- src: manpages/https-wrench-completion.1.gz
dst: /usr/share/man/man1/https-wrench-completion.1.gz

- src: manpages/https-wrench-completion-bash.1.gz
dst: /usr/share/man/man1/https-wrench-completion-bash.1.gz

- src: manpages/https-wrench-completion-fish.1.gz
dst: /usr/share/man/man1/https-wrench-completion-fish.1.gz

- src: manpages/https-wrench-completion-zsh.1.gz
dst: /usr/share/man/man1/https-wrench-completion-zsh.1.gz

release: "1"

dockers:
Expand Down Expand Up @@ -130,6 +153,12 @@ homebrew_casks:
description: https-wrench
license: MIT
skip_upload: false

manpages:
- ./manpages/https-wrench.1.gz
- ./manpages/https-wrench-requests.1.gz
- ./manpages/https-wrench-certinfo.1.gz

completions:
bash: "completions/{{ .ProjectName }}.bash"
zsh: "completions/{{ .ProjectName }}.zsh"
Expand All @@ -146,11 +175,13 @@ nix:
license: mit

extra_install: |-
installManPage ./manpages/https-wrench.1.gz
installManPage ./manpages/https-wrench-certinfo.1.gz
installManPage ./manpages/https-wrench-requests.1.gz
installShellCompletion --cmd https-wrench \
--bash <($out/bin/https-wrench completion bash) \
--fish <($out/bin/https-wrench completion fish) \
--zsh <($out/bin/https-wrench completion zsh)
# installManPage ./manpages/foo.1.gz

changelog:
sort: asc
Expand Down
31 changes: 17 additions & 14 deletions cmd/certinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,31 @@ var (

var certinfoCmd = &cobra.Command{
Use: "certinfo",
Short: "Show info about PEM certificates and keys",
Short: "Shows information about PEM certificates and keys",
Long: `
HTTPS Wrench certinfo: show info about PEM certificates and keys.
HTTPS Wrench certinfo: shows information about PEM certificates and keys.

https-wrench certinfo can fetch certificates from a TLS endpoint, read from a PEM bundle file, and check if a
private key matches any of the certificates.

Certinfo can fetch certificates from a TLS endpoint, read from a PEM bundle file, and check if a private
key matches any of the certificates.
The certificates can be verified against the system root CAs or a custom CA bundle file.

The validation can be skipped.

If the private key is password protected, the password can be provided via the CERTINFO_PKEY_PW
environment variable or will be prompted on stdin.

Examples:
certinfo --tls-endpoint example.com:443
certinfo --cert-bundle ./bundle.pem --key-file ./key.pem
certinfo --cert-bundle ./bundle.pem
certinfo --key-file ./key.pem
certinfo --tls-endpoint example.com:443 --key-file ./key.pem
certinfo --tls-endpoint example.com:443 --cert-bundle ./bundle.pem --key-file ./key.pem
certinfo --tls-endpoint example.com:443 --tls-servername www.example.com
certinfo --tls-endpoint [2001:db8::1]:443 --tls-insecure
certinfo --ca-bundle ./ca-bundle.pem --tls-endpoint example.com:443
certinfo --ca-bundle ./ca-bundle.pem --cert-bundle ./bundle.pem --key-file ./key.pem
https-wrench certinfo --tls-endpoint example.com:443
https-wrench certinfo --cert-bundle ./bundle.pem --key-file ./key.pem
https-wrench certinfo --cert-bundle ./bundle.pem
https-wrench certinfo --key-file ./key.pem
https-wrench certinfo --tls-endpoint example.com:443 --key-file ./key.pem
https-wrench certinfo --tls-endpoint example.com:443 --cert-bundle ./bundle.pem --key-file ./key.pem
https-wrench certinfo --tls-endpoint example.com:443 --tls-servername www.example.com
https-wrench certinfo --tls-endpoint [2001:db8::1]:443 --tls-insecure
https-wrench certinfo --ca-bundle ./ca-bundle.pem --tls-endpoint example.com:443
https-wrench certinfo --ca-bundle ./ca-bundle.pem --cert-bundle ./bundle.pem --key-file ./key.pem
`,
Run: func(cmd *cobra.Command, args []string) {
caBundleValue := viper.GetString("ca-bundle")
Expand Down
42 changes: 42 additions & 0 deletions cmd/man.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
Copyright © 2025 Zeno Belli <xeno@os76.xyz>
*/

package cmd

import (
"fmt"
"time"

"github.com/spf13/cobra"
"github.com/spf13/cobra/doc"
)

var manPagesDestDir string

var manCmd = &cobra.Command{
Use: "man",
Short: "create manpages for HTTPS Wrench",
Long: "Create manpages for HTTPS Wrench commands",
Hidden: true,
Run: func(_ *cobra.Command, _ []string) {
now := time.Now()
rootHeader := &doc.GenManHeader{
Title: "HTTPS-WRENCH",
Section: "1",
Date: &now,
Source: "https-wrench",
}
err := doc.GenManTree(rootCmd, rootHeader, manPagesDestDir)
if err != nil {
fmt.Print(err)
return
}
},
}

func init() {
rootCmd.AddCommand(manCmd)
manCmd.Flags().StringVar(&manPagesDestDir, "dest-dir",
".", "Destination directory for the man pages files")
}
16 changes: 15 additions & 1 deletion cmd/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,21 @@ var requestsCmd = &cobra.Command{
Use: "requests",
Short: "Make HTTPS requests defined in the YAML configuration file",
Long: `
HTTPS Wrench requests: make HTTPS requests defined in the YAML configuration file`,
https-wrench requests is the subcommand that does HTTPS requests according to the configuration
pointed by the --config flag.

A sample configuration can be generated as a starting point (--show-sample-config).

The Github repository has more configuration examples:
https://github.com/xenOs76/https-wrench/tree/main/assets/examples

It also provides a JSON schema that can be used to validate new configuration files:
https://github.com/xenOs76/https-wrench/blob/main/https-wrench.schema.json

Examples:
https-wrench requests --show-sample-config > https-wrench-sample-config.yaml
https-wrench requests --config https-wrench-sample-config.yaml
`,

Run: func(cmd *cobra.Command, args []string) {
versionRequested := viper.GetBool("version")
Expand Down
15 changes: 14 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,20 @@ var rootCmd = &cobra.Command{
Use: "https-wrench",
Short: "HTTPS Wrench, a tool to make HTTPS requests based on a YAML configuration file",
Long: `
HTTPS Wrench, a tool to make HTTPS requests based on a YAML configuration file`,
HTTPS Wrench is mainly a tool to make HTTPS requests based on a YAML configuration file.

https-wrench has two subcommands: requests and certinfo.

requests is the subcommand that does HTTPS requests according to the configuration provided
by the --config flag.

certinfo is a subcommand that reads information from PEM certificates and keys. The certificates
can be read from local files or TLS enabled endpoints.

certinfo can compare public keys extracted from certificates and private keys to check if they match.

HTTPS Wrench is distributed with an open source license and available at the following address:
https://github.com/xenOs76/https-wrench`,

Run: func(cmd *cobra.Command, args []string) {
showVersion, _ := cmd.Flags().GetBool("version")
Expand Down
8 changes: 7 additions & 1 deletion devenv.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
".gitignore"
".envrc"
"internal/certinfo/common_handlers.go"
"completions"
"completions/*"
];
hooks = {
shellcheck.enable = true;
Expand Down Expand Up @@ -238,6 +238,11 @@
./dist/https-wrench certinfo | grep "help for certinfo"
'';

scripts.test-requests-show-sample-config.exec = ''
gum format "## test request show sample config"
./dist/https-wrench requests --show-sample-config| grep 'requests:'
'';

scripts.test-requests-sample-config.exec = ''
gum format "## test request with sample config"
./dist/https-wrench requests --config ./cmd/embedded/config-example.yaml
Expand Down Expand Up @@ -504,6 +509,7 @@
gum format "## Requests tests"

# test-requests-sample-config
test-requests-show-sample-config
test-requests-k3s
test-requests-methods
test-requests-timeout
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ require (
github.com/clipperhouse/displaywidth v0.6.0 // indirect
github.com/clipperhouse/stringish v0.1.1 // indirect
github.com/clipperhouse/uax29/v2 v2.3.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.6 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dlclark/regexp2 v1.11.5 // indirect
github.com/fsnotify/fsnotify v1.9.0 // indirect
Expand All @@ -42,6 +43,7 @@ require (
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sagikazarmark/locafero v0.12.0 // indirect
github.com/spf13/afero v1.15.0 // indirect
github.com/spf13/cast v1.10.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ github.com/clipperhouse/stringish v0.1.1 h1:+NSqMOr3GR6k1FdRhhnXrLfztGzuG+VuFDfa
github.com/clipperhouse/stringish v0.1.1/go.mod h1:v/WhFtE1q0ovMta2+m+UbpZ+2/HEXNWYXQgCt4hdOzA=
github.com/clipperhouse/uax29/v2 v2.3.0 h1:SNdx9DVUqMoBuBoW3iLOj4FQv3dN5mDtuqwuhIGpJy4=
github.com/clipperhouse/uax29/v2 v2.3.0/go.mod h1:Wn1g7MK6OoeDT0vL+Q0SQLDz/KpfsVRgg6W7ihQeh4g=
github.com/cpuguy83/go-md2man/v2 v2.0.6 h1:XJtiaUW6dEEqVuZiMTn1ldk455QWwEIsMIJlo5vtkx0=
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down Expand Up @@ -73,6 +74,7 @@ github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sagikazarmark/locafero v0.12.0 h1:/NQhBAkUb4+fH1jivKHWusDYFjMOOKU88eegjfxfHb4=
github.com/sagikazarmark/locafero v0.12.0/go.mod h1:sZh36u/YSZ918v0Io+U9ogLYQJ9tLLBmM4eneO6WwsI=
Expand Down
Loading