Skip to content
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
5 changes: 5 additions & 0 deletions cmd/mdmb/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"time"

"github.com/jessepeterson/mdmb/internal/device"
"github.com/jessepeterson/mdmb/scepclient"
bolt "go.etcd.io/bbolt"
)

Expand Down Expand Up @@ -71,6 +72,7 @@ func main() {
var (
dbPath = f.String("db", "mdmb.db", "mdmb database file path")
uuids = f.String("uuids", "", "comma-separated list of device UUIDs, '-' to read from stdin, or 'all' for all devices")
contentType = f.String("content-type", "application/x-pki-message", "HTTP Content-Type for SCEP POST PKIOperation requests")
)
f.Usage = func() {
fmt.Fprintf(f.Output(), "%s [flags] <subcommand> [flags]\n", f.Name())
Expand Down Expand Up @@ -125,6 +127,9 @@ func main() {
}
}


scepclient.RequestContentType = *contentType

for _, sc := range subCmds {
if f.Args()[0] == sc.Name {
sc.Func(sc.Name, f.Args()[1:], rctx, f.Usage)
Expand Down
4 changes: 3 additions & 1 deletion scepclient/scepclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import (
"github.com/smallstep/scep"
)

var RequestContentType = "application/x-pki-message"
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally we want to stay away from global variables. This can just be a property on the client struct (since that's where it's used) and initialized as an option in the client.


// Doer executes an HTTP request.
type Doer interface {
// Execute HTTP request.
Expand Down Expand Up @@ -109,7 +111,7 @@ func (c *Client) do(ctx context.Context, op string, message []byte) (*http.Respo

if method == http.MethodPost {
// some servers/proxies have problems without a content-type
req.Header.Set("Content-Type", "application/octet-stream")
req.Header.Set("Content-Type", RequestContentType)
}

return c.doer.Do(req)
Expand Down