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

🧹 Test provided cert/pass when creating an ms365 connection. #1162

Merged
merged 2 commits into from
May 2, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 6 additions & 0 deletions motor/discovery/ms365/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ func (r *Resolver) Resolve(ctx context.Context, root *asset.Asset, cc *providers
return nil, err
}

// try getting a token, this wil err out if the pem/pfx file are wrong or if the password
// is wrong. allows for returning an err early
_, err = provider.GetTokenCredential()
if err != nil {
return nil, err
}
// detect platform info for the asset
pf, err := m.Platform()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion motor/providers/microsoft/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func (p *Provider) GetTokenCredential() (azcore.TokenCredential, error) {
case vault.CredentialType_pkcs12:
certs, privateKey, err := azidentity.ParseCertificates(p.cred.Secret, []byte(p.cred.Password))
if err != nil {
return nil, errors.Wrap(err, "could not parse certificate")
return nil, errors.Wrap(err, "could not parse provided certificate")
preslavgerchev marked this conversation as resolved.
Show resolved Hide resolved
}

credential, err = azidentity.NewClientCertificateCredential(p.tenantID, p.clientID, certs, privateKey, &azidentity.ClientCertificateCredentialOptions{})
Expand Down