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 some accessors for context options and extra validation #508

Merged
merged 1 commit into from
Dec 18, 2023
Merged
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
13 changes: 13 additions & 0 deletions natscontext/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,10 @@ func (c *Context) Validate() error {
}
}

if c.config.WinCertStoreType != "" && c.config.WinCertStoreMatch == "" {
return fmt.Errorf("windows certificate store requires a matcher")
}

return nil
}

Expand Down Expand Up @@ -906,16 +910,25 @@ func (c *Context) WithWindowsCertStore(storeType string) Option {
}
}

// WindowsCertStore indicates if the cert store should be used and which type
func (c *Context) WindowsCertStore() string { return c.config.WinCertStoreType }

// WithWindowsCertStoreMatchBy configures Matching behavior for Windows Certificate Store. Valid values are "issuer" or "subject"
func (c *Context) WithWindowsCertStoreMatchBy(matchBy string) Option {
return func(s *settings) {
c.config.WinCertStoreMatchBy = matchBy
}
}

// WindowsCertStoreMatchBy indicates which property will be used to search in the store
func (c *Context) WindowsCertStoreMatchBy() string { return c.config.WinCertStoreMatchBy }

// WithWindowsCertStoreMatch configures the matcher query to select certificates with, see WithWindowsCertStoreMatchBy
func (c *Context) WithWindowsCertStoreMatch(match string) Option {
return func(s *settings) {
c.config.WinCertStoreMatch = match
}
}

// WindowsCertStoreMatch is the string to use when searching a certificate in the windows certificate store
func (c *Context) WindowsCertStoreMatch() string { return c.config.WinCertStoreMatch }