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

fix(dps-service): Remove client side validation of x509 CA references format #2172

Merged
merged 3 commits into from
Sep 24, 2021
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
5 changes: 0 additions & 5 deletions provisioning/service/src/Config/X509CAReferences.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ public class X509CAReferences
[JsonConstructor]
Copy link
Contributor

Choose a reason for hiding this comment

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

You'd need to clean up the param note about it not being allowed to be null or empty.

internal X509CAReferences(string primary, string secondary = null)
{
/* SRS_X509_CAREFERENCE_21_001: [The constructor shall throw ArgumentException if the primary CA reference is null or empty.] */
if(string.IsNullOrWhiteSpace(primary))
Copy link
Member

Choose a reason for hiding this comment

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

In which scenario would we expect this to happen, i.e. all CA refs to be empty?

Copy link
Member Author

Choose a reason for hiding this comment

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

Had a conversation with the DPS service folks and they confirmed both CA references can be null if the enrollment group is using symmetric keys, client certificates or signing certificates.

Copy link
Member

Choose a reason for hiding this comment

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

Primary and secondary are the only properties on this class. If both are null, then is there a valid case for this type even being initialized, i.e. if the enrollment group is using symmetric keys, client certificates or signing certificates => these refs are null but we'd still expect X509CAReferences to be initialized?

Copy link
Member Author

Choose a reason for hiding this comment

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

It may be better for the service not to return the CA references object if all its contents are null, sure. However, the SDK appears to be receiving them from the service in cases like that anyways.

{
throw new ProvisioningServiceClientException("Primary CA reference cannot be null or empty");
}
/* SRS_X509_CAREFERENCE_21_002: [The constructor shall store the primary and secondary CA references.] */
Primary = primary;
Secondary = secondary;
Expand Down
14 changes: 0 additions & 14 deletions provisioning/service/tests/Config/X509CAReferencesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,6 @@ namespace Microsoft.Azure.Devices.Provisioning.Service.Test
[TestCategory("Unit")]
public class X509CAReferencesTests
{
/* SRS_X509_CAREFERENCE_21_001: [The constructor shall throw ArgumentException if the primary CA reference is null or empty.] */

[TestMethod]
public void X509CAReferencesThrowsOnInvalidPrimaryReferences()
{
// act and assert
#pragma warning disable CA1806 // Do not ignore method results
TestAssert.Throws<ProvisioningServiceClientException>(() => new X509CAReferences(null));
TestAssert.Throws<ProvisioningServiceClientException>(() => new X509CAReferences(""));
TestAssert.Throws<ProvisioningServiceClientException>(() => new X509CAReferences(" "));
TestAssert.Throws<ProvisioningServiceClientException>(() => new X509CAReferences(null, "valid-ca-reference"));
#pragma warning restore CA1806 // Do not ignore method results
}

/* SRS_X509_CAREFERENCE_21_002: [The constructor shall store the primary and secondary CA references.] */

[TestMethod]
Expand Down