Skip to content

Commit c199ddd

Browse files
committed
Added extra Unix-specific exceptions
Converting more unusually-embedded PFX files into embedded resources
1 parent d932272 commit c199ddd

File tree

14 files changed

+369
-29
lines changed

14 files changed

+369
-29
lines changed

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlUtil.cs

+40-8
Original file line numberDiff line numberDiff line change
@@ -1696,14 +1696,29 @@ internal static Exception LargeCertificatePathLength(int actualLength, int maxLe
16961696

16971697
internal static Exception NullCertificatePath(string[] validLocations, bool isSystemOp)
16981698
{
1699-
Debug.Assert(2 == validLocations.Length);
1700-
if (isSystemOp)
1699+
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
17011700
{
1702-
return ADP.ArgumentNull(TdsEnums.TCE_PARAM_MASTERKEY_PATH, StringsHelper.GetString(Strings.TCE_NullCertificatePathSysErr, validLocations[0], validLocations[1], @"/"));
1701+
Debug.Assert(validLocations.Length == 2);
1702+
if (isSystemOp)
1703+
{
1704+
return ADP.ArgumentNull(TdsEnums.TCE_PARAM_MASTERKEY_PATH, StringsHelper.GetString(Strings.TCE_NullCertificatePathSysErr, validLocations[0], validLocations[1], @"/"));
1705+
}
1706+
else
1707+
{
1708+
return ADP.ArgumentNull(TdsEnums.TCE_PARAM_MASTERKEY_PATH, StringsHelper.GetString(Strings.TCE_NullCertificatePath, validLocations[0], validLocations[1], @"/"));
1709+
}
17031710
}
17041711
else
17051712
{
1706-
return ADP.ArgumentNull(TdsEnums.TCE_PARAM_MASTERKEY_PATH, StringsHelper.GetString(Strings.TCE_NullCertificatePath, validLocations[0], validLocations[1], @"/"));
1713+
Debug.Assert(validLocations.Length == 1);
1714+
if (isSystemOp)
1715+
{
1716+
return ADP.ArgumentNull(TdsEnums.TCE_PARAM_MASTERKEY_PATH, StringsHelper.GetString(Strings.TCE_NullCertificatePathSysErr_Unix, validLocations[0], @"/"));
1717+
}
1718+
else
1719+
{
1720+
return ADP.ArgumentNull(TdsEnums.TCE_PARAM_MASTERKEY_PATH, StringsHelper.GetString(Strings.TCE_NullCertificatePath_Unix, validLocations[0], @"/"));
1721+
}
17071722
}
17081723
}
17091724

@@ -1733,14 +1748,29 @@ internal static Exception NullCngKeyPath(bool isSystemOp)
17331748

17341749
internal static Exception InvalidCertificatePath(string actualCertificatePath, string[] validLocations, bool isSystemOp)
17351750
{
1736-
Debug.Assert(2 == validLocations.Length);
1737-
if (isSystemOp)
1751+
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
17381752
{
1739-
return ADP.Argument(StringsHelper.GetString(Strings.TCE_InvalidCertificatePathSysErr, actualCertificatePath, validLocations[0], validLocations[1], @"/"), TdsEnums.TCE_PARAM_MASTERKEY_PATH);
1753+
Debug.Assert(validLocations.Length == 2);
1754+
if (isSystemOp)
1755+
{
1756+
return ADP.Argument(StringsHelper.GetString(Strings.TCE_InvalidCertificatePathSysErr, actualCertificatePath, validLocations[0], validLocations[1], @"/"), TdsEnums.TCE_PARAM_MASTERKEY_PATH);
1757+
}
1758+
else
1759+
{
1760+
return ADP.Argument(StringsHelper.GetString(Strings.TCE_InvalidCertificatePath, actualCertificatePath, validLocations[0], validLocations[1], @"/"), TdsEnums.TCE_PARAM_MASTERKEY_PATH);
1761+
}
17401762
}
17411763
else
17421764
{
1743-
return ADP.Argument(StringsHelper.GetString(Strings.TCE_InvalidCertificatePath, actualCertificatePath, validLocations[0], validLocations[1], @"/"), TdsEnums.TCE_PARAM_MASTERKEY_PATH);
1765+
Debug.Assert(validLocations.Length == 1);
1766+
if (isSystemOp)
1767+
{
1768+
return ADP.Argument(StringsHelper.GetString(Strings.TCE_InvalidCertificatePathSysErr_Unix, actualCertificatePath, validLocations[0], @"/"), TdsEnums.TCE_PARAM_MASTERKEY_PATH);
1769+
}
1770+
else
1771+
{
1772+
return ADP.Argument(StringsHelper.GetString(Strings.TCE_InvalidCertificatePath_Unix, actualCertificatePath, validLocations[0], @"/"), TdsEnums.TCE_PARAM_MASTERKEY_PATH);
1773+
}
17441774
}
17451775
}
17461776

@@ -1856,6 +1886,7 @@ internal static Exception InvalidCertificateLocation(string certificateLocation,
18561886
{
18571887
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
18581888
{
1889+
Debug.Assert(validLocations.Length == 2);
18591890
if (isSystemOp)
18601891
{
18611892
return ADP.Argument(StringsHelper.GetString(Strings.TCE_InvalidCertificateLocationSysErr, certificateLocation, certificatePath, validLocations[0], validLocations[1], @"/"), TdsEnums.TCE_PARAM_MASTERKEY_PATH);
@@ -1867,6 +1898,7 @@ internal static Exception InvalidCertificateLocation(string certificateLocation,
18671898
}
18681899
else
18691900
{
1901+
Debug.Assert(validLocations.Length == 1);
18701902
if (isSystemOp)
18711903
{
18721904
return ADP.Argument(StringsHelper.GetString(Strings.TCE_InvalidCertificateLocationSysErr_Unix, certificateLocation, certificatePath, validLocations[0], @"/"), TdsEnums.TCE_PARAM_MASTERKEY_PATH);

src/Microsoft.Data.SqlClient/src/Resources/Strings.Designer.cs

+48-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Microsoft.Data.SqlClient/src/Resources/Strings.resx

+12
Original file line numberDiff line numberDiff line change
@@ -4035,9 +4035,15 @@
40354035
<data name="TCE_NullCertificatePath" xml:space="preserve">
40364036
<value>Certificate path cannot be null. Use the following format: &lt;certificate location&gt;{2}&lt;certificate store&gt;{2}&lt;certificate thumbprint&gt;, where &lt;certificate location&gt; is either '{0}' or '{1}'.</value>
40374037
</data>
4038+
<data name="TCE_NullCertificatePath_Unix" xml:space="preserve">
4039+
<value>Certificate path cannot be null. Use the following format: &lt;certificate location&gt;{1}&lt;certificate store&gt;{1}&lt;certificate thumbprint&gt;, where &lt;certificate location&gt; is '{0}'.</value>
4040+
</data>
40384041
<data name="TCE_NullCertificatePathSysErr" xml:space="preserve">
40394042
<value>Internal error. Certificate path cannot be null. Use the following format: &lt;certificate location&gt;{2}&lt;certificate store&gt;{2}&lt;certificate thumbprint&gt;, where &lt;certificate location&gt; is either '{0}' or '{1}'.</value>
40404043
</data>
4044+
<data name="TCE_NullCertificatePathSysErr_Unix" xml:space="preserve">
4045+
<value>Internal error. Certificate path cannot be null. Use the following format: &lt;certificate location&gt;{1}&lt;certificate store&gt;{1}&lt;certificate thumbprint&gt;, where &lt;certificate location&gt; is '{0}'.</value>
4046+
</data>
40414047
<data name="TCE_NullCspPath" xml:space="preserve">
40424048
<value>Column master key path cannot be null. Use the following format for a key stored in a Microsoft cryptographic service provider (CSP): &lt;CSP Provider Name&gt;{0}&lt;Key Identifier&gt;.</value>
40434049
</data>
@@ -4053,9 +4059,15 @@
40534059
<data name="TCE_InvalidCertificatePath" xml:space="preserve">
40544060
<value>Invalid certificate path: '{0}'. Use the following format: &lt;certificate location&gt;{3}&lt;certificate store&gt;{3}&lt;certificate thumbprint&gt;, where &lt;certificate location&gt; is either '{1}' or '{2}'.</value>
40554061
</data>
4062+
<data name="TCE_InvalidCertificatePath_Unix" xml:space="preserve">
4063+
<value>Invalid certificate path: '{0}'. Use the following format: &lt;certificate location&gt;{2}&lt;certificate store&gt;{2}&lt;certificate thumbprint&gt;, where &lt;certificate location&gt; is '{1}'.</value>
4064+
</data>
40564065
<data name="TCE_InvalidCertificatePathSysErr" xml:space="preserve">
40574066
<value>Internal error. Invalid certificate path: '{0}'. Use the following format: &lt;certificate location&gt;{3}&lt;certificate store&gt;{3}&lt;certificate thumbprint&gt;, where &lt;certificate location&gt; is either '{1}' or '{2}'.</value>
40584067
</data>
4068+
<data name="TCE_InvalidCertificatePathSysErr_Unix" xml:space="preserve">
4069+
<value>Internal error. Invalid certificate path: '{0}'. Use the following format: &lt;certificate location&gt;{2}&lt;certificate store&gt;{2}&lt;certificate thumbprint&gt;, where &lt;certificate location&gt; is '{1}'.</value>
4070+
</data>
40594071
<data name="TCE_InvalidCspPath" xml:space="preserve">
40604072
<value>Invalid column master key path: '{0}'. Use the following format for a key stored in a Microsoft cryptographic service provider (CSP): &lt;CSP Provider Name&gt;{1}&lt;Key Identifier&gt;.</value>
40614073
</data>

0 commit comments

Comments
 (0)