Skip to content

Conversation

hiyosi
Copy link
Contributor

@hiyosi hiyosi commented Mar 13, 2023

Pull Request check list

  • Commit conforms to CONTRIBUTING.md?
  • Proper tests/regressions included?
  • Documentation updated?

Affected functionality

Description of change

Fixed a issue in which intermediate certificates issued by the HashiCorp Vault PKI engine do not contain a URI SAN.

Which issue this PR fixes

#3968

@hiyosi hiyosi force-pushed the specify-uri-sans branch 3 times, most recently from 8a7207f to 8daa8ed Compare March 13, 2023 09:50
@amartinezfayo amartinezfayo added this to the 1.6.2 milestone Mar 13, 2023
@@ -259,7 +259,7 @@ func TestMintX509CA(t *testing.T) {
},
},
authMethod: TOKEN,
expectX509CA: []string{"spiffe://intermediate-vault", "spiffe://intermediate"},
expectX509CA: []string{"spiffe://intermediate-spire", "spiffe://intermediate-vault"},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Before this PR, values of URI SAN are little confusing.

@hiyosi hiyosi force-pushed the specify-uri-sans branch from 372de14 to 03becc4 Compare March 15, 2023 01:09
@amartinezfayo amartinezfayo self-assigned this Mar 15, 2023
Copy link
Member

@amartinezfayo amartinezfayo left a comment

Choose a reason for hiding this comment

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

Thank you @hiyosi for this contribution!
This is in draft mode, are you expecting to add more commits?

@hiyosi
Copy link
Contributor Author

hiyosi commented Mar 15, 2023

@amartinezfayo
I have only one concern.
I'm not sure a value of URI SAN(SPIFFE ID) must be set or not in X509SVID CA certificates.

@hiyosi hiyosi marked this pull request as ready for review March 15, 2023 22:50
@amartinezfayo
Copy link
Member

I'm not sure a value of URI SAN(SPIFFE ID) must be set or not in X509SVID CA certificates.

While it would be desirable that a signing certificate itself should an SVID, it's not mandatory.
A more strict validation was introduced in SPIRE 1.6 that made this a hard requirement. After discussing this during our last maintainer's sync, we decided that it's better to relax that requirement so the process doesn't fail. There are chances that an upstream authority plugin can't control this, so we will change this to not have an unnecessary limitation there.

We still welcome this change though :)

uris = append(uris, uri.String())
}
if len(uris) == 0 {
return nil, status.Errorf(codes.Internal, "CSR must have least one URIs")
Copy link
Member

Choose a reason for hiding this comment

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

Since the error is due to an invalid input argument and not an internal failure I think that we should use codes.InvalidArgument.

Suggested change
return nil, status.Errorf(codes.Internal, "CSR must have least one URIs")
return nil, status.Errorf(codes.InvalidArgument, "CSR must have at least one URI")

Copy link
Contributor Author

@hiyosi hiyosi Mar 17, 2023

Choose a reason for hiding this comment

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

fixed via a0ee7fd

@hiyosi hiyosi force-pushed the specify-uri-sans branch from f9b6103 to a0ee7fd Compare March 17, 2023 22:48
Copy link
Member

@amartinezfayo amartinezfayo left a comment

Choose a reason for hiding this comment

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

Last final thing and we are ready to go. Sorry that I didn't suggest this in the first review.

uris = append(uris, uri.String())
}
if len(uris) == 0 {
return nil, status.Errorf(codes.InvalidArgument, "CSR must have least one URIs")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return nil, status.Errorf(codes.InvalidArgument, "CSR must have least one URIs")
return nil, status.Errorf(codes.InvalidArgument, "CSR must have at least one URI")

Copy link
Contributor Author

@hiyosi hiyosi Mar 21, 2023

Choose a reason for hiding this comment

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

Fixed via 6bfee67

@hiyosi hiyosi force-pushed the specify-uri-sans branch from 5a59969 to f34b40b Compare March 21, 2023 22:58
@hiyosi hiyosi force-pushed the specify-uri-sans branch from f34b40b to 6bfee67 Compare March 21, 2023 22:59
Copy link
Member

@amartinezfayo amartinezfayo left a comment

Choose a reason for hiding this comment

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

Thank you @hiyosi!

@amartinezfayo amartinezfayo merged commit f9c4b87 into spiffe:main Mar 22, 2023
@hiyosi hiyosi deleted the specify-uri-sans branch March 22, 2023 22:56
@amartinezfayo amartinezfayo modified the milestones: 1.6.2, 1.6.3 Apr 5, 2023
Basavaraju-G pushed a commit to Basavaraju-G/spire that referenced this pull request May 3, 2023
* Make sure to set uri_sans parameter

Signed-off-by: Tomoya Usami <[email protected]>
Signed-off-by: Basavaraju-G <[email protected]>
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.

2 participants