Skip to content

Commit

Permalink
Merge pull request #508 from ripienaar/windows_cert_store
Browse files Browse the repository at this point in the history
Add some accessors for context options and extra validation
  • Loading branch information
ripienaar authored Dec 18, 2023
2 parents 3c72e19 + 2b7422a commit 63d355f
Showing 1 changed file with 13 additions and 0 deletions.
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 }

0 comments on commit 63d355f

Please sign in to comment.