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

Setup intermediate_pki_path on secondary #8001

Merged
merged 1 commit into from
Jun 5, 2020

Conversation

hanshasselberg
Copy link
Member

Make sure to mount vault backend for intermediate_pki_path on secondary
dc.

Make sure to mount vault backend for intermediate_pki_path on secondary
dc.
@hanshasselberg hanshasselberg changed the title Setup intermediate_pki_path on secondary when using vault Setup intermediate_pki_path on secondary Jun 2, 2020
@@ -231,7 +244,22 @@ func (v *VaultProvider) SetIntermediate(intermediatePEM, rootPEM string) error {

// ActiveIntermediate returns the current intermediate certificate.
func (v *VaultProvider) ActiveIntermediate() (string, error) {
return v.getCA(v.config.IntermediatePKIPath)
if err := v.setupIntermediatePKIPath(); err != nil {
Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure it is the best way to make sure everything is setup in here, but I didn't find a better place. Using setupIntermediatePKIPathDone as a guard to make sure the setup is only done once.

Copy link
Member

@mkeeler mkeeler left a comment

Choose a reason for hiding this comment

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

LGTM

}
}
v.setupIntermediatePKIPathDone = true
Copy link
Member

Choose a reason for hiding this comment

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

Does this need a mutex or is it only accessed by a single goroutine?

Copy link
Member Author

@hanshasselberg hanshasselberg Jun 4, 2020

Choose a reason for hiding this comment

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

There are two different flows.

The leader in the primary dc calls this the first time in initializeRootCA while holding caProviderReconfigurationLock:

// Also create the intermediate CA, which is the one that actually signs leaf certs
interPEM, err := provider.GenerateIntermediate()
if err != nil {
return fmt.Errorf("error generating intermediate cert: %v", err)
}

The leader in a secondary dc calls this the first time in initializeSecondaryCA while holding caProviderReconfigurationLock:

activeIntermediate, err := provider.ActiveIntermediate()
if err != nil {
return err
}

An error will prevent the initialization to move on and and it will be retried later. I think this is safe to do. However I considered using atomic just to make sure we don't shoot our foot in case the other code changes.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good.

@hanshasselberg hanshasselberg merged commit 5281cb7 into master Jun 5, 2020
@hanshasselberg hanshasselberg deleted the connect_secondary_vault_setupintermediate branch June 5, 2020 19:36
hashicorp-ci pushed a commit that referenced this pull request Jun 5, 2020
Make sure to mount vault backend for intermediate_pki_path on secondary
dc.
hashicorp-ci pushed a commit that referenced this pull request Jun 5, 2020
Make sure to mount vault backend for intermediate_pki_path on secondary
dc.
@david-yu
Copy link
Contributor

david-yu commented Jun 9, 2020

Hi @i0rek Would it be possible to bring this in for beta3? cc @mikemorris

@mikemorris
Copy link
Contributor

mikemorris commented Jun 11, 2020

@david-yu Yep, this was merged into the release/1.8.x branch in c675166 and will be included in 1.8.0-beta3 when that happens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants