Skip to content

Commit 36f312b

Browse files
bartonjsgewarren
authored andcommitted
Add/update documentation for the X509Certificates namespace. (#3669)
* Add/update documentation for the X509Certificates namespace. * Remove redundant tag close. * Apply suggestions from code review Co-Authored-By: Carlos Sanchez Lopez <[email protected]> * Apply suggestions from code review Co-Authored-By: Carlos Sanchez Lopez <[email protected]> * Apply suggestions from code review Co-Authored-By: Genevieve Warren <[email protected]>
1 parent 16de181 commit 36f312b

File tree

7 files changed

+268
-89
lines changed

7 files changed

+268
-89
lines changed

xml/System.Security.Cryptography.X509Certificates/X509Certificate.xml

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1665,6 +1665,11 @@
16651665
<summary>Returns the hash value for the X.509v3 certificate that is computed by using the specified cryptographic hash algorithm.</summary>
16661666
<returns>A byte array that contains the hash value for the X.509 certificate.</returns>
16671667
<remarks>To be added.</remarks>
1668+
<exception cref="T:System.ArgumentException">
1669+
<paramref name="hashAlgorithm" />.<see cref="P:System.Security.Cryptography.HashAlgorithmName.Name" /> is <see langword="null" /> or an empty string.</exception>
1670+
<exception cref="T:System.Security.Cryptography.CryptographicException">
1671+
<paramref name="hashAlgorithm" /> is not a known hash algorithm.</exception>
1672+
<altmember cref="M:System.Security.Cryptography.X509Certificates.X509Certificate.TryGetCertHash(System.Security.Cryptography.HashAlgorithmName,System.Span{System.Byte},System.Int32@)" />
16681673
</Docs>
16691674
</Member>
16701675
<MemberGroup MemberName="GetCertHashString">
@@ -1751,6 +1756,10 @@
17511756
<summary>Returns a hexadecimal string containing the hash value for the X.509v3 certificate computed using the specified cryptographic hash algorithm.</summary>
17521757
<returns>The hexadecimal string representation of the X.509 certificate hash value.</returns>
17531758
<remarks>To be added.</remarks>
1759+
<exception cref="T:System.ArgumentException">
1760+
<paramref name="hashAlgorithm" />.<see cref="P:System.Security.Cryptography.HashAlgorithmName.Name" /> is <see langword="null" /> or an empty string.</exception>
1761+
<exception cref="T:System.Security.Cryptography.CryptographicException">
1762+
<paramref name="hashAlgorithm" /> is not a known hash algorithm.</exception>
17541763
</Docs>
17551764
</Member>
17561765
<Member MemberName="GetEffectiveDateString">
@@ -2320,6 +2329,8 @@
23202329
<returns>The public key for the X.509 certificate as an array of bytes.</returns>
23212330
<remarks>
23222331
<format type="text/markdown"><![CDATA[
2332+
## Remarks
2333+
This value corresponds to the contents of the `subjectPublicKey` field of the SubjectPublicKeyInfo data within the certificate.
23232334
23242335
## Examples
23252336
The following example uses the <xref:System.Security.Cryptography.X509Certificates.X509Certificate.GetPublicKey%2A> method to return a certificate's public key as an array of bytes and displays it to the console.
@@ -2368,6 +2379,8 @@
23682379
<returns>The public key for the X.509 certificate as a hexadecimal string.</returns>
23692380
<remarks>
23702381
<format type="text/markdown"><![CDATA[
2382+
## Remarks
2383+
This value corresponds to the contents of the `subjectPublicKey` field of the SubjectPublicKeyInfo data within the certificate.
23712384
23722385
## Examples
23732386
The following example uses the <xref:System.Security.Cryptography.X509Certificates.X509Certificate.GetPublicKeyString%2A> method to return a certificate's public key as a string and displays it to the console.
@@ -2420,6 +2433,8 @@
24202433
<returns>A byte array containing the X.509 certificate data.</returns>
24212434
<remarks>
24222435
<format type="text/markdown"><![CDATA[
2436+
## Remarks
2437+
The output of this method is equivalent to the output of the <xref:System.Security.Cryptography.X509Certificates.X509Certificate.Export%2A> method with an output encoding of <xref:System.Security.Cryptography.X509Certificates.X509ContentType.Cert?displayProperty=nameWithType>.
24232438
24242439
## Examples
24252440
The following example uses the <xref:System.Security.Cryptography.X509Certificates.X509Certificate.GetRawCertData%2A> method to return a certificate's raw data as an array of bytes and displays it to the console.
@@ -2702,6 +2717,7 @@
27022717
<permission cref="T:System.Security.SecurityCriticalAttribute">requires full trust for the immediate caller. This class cannot be used by partially trusted or transparent code.</permission>
27032718
<permission cref="F:System.Security.Permissions.SecurityAction.InheritanceDemand">for full trust for inheritors. This member cannot be inherited by partially trusted code.</permission>
27042719
<permission cref="T:System.Security.Permissions.KeyContainerPermission">for permission to create a key container. Security action: <see cref="F:System.Security.Permissions.SecurityAction.Demand" />. Associated enumeration: <see cref="F:System.Security.Permissions.KeyContainerPermissionFlags.Create" /></permission>
2720+
<exception cref="T:System.PlatformNotSupportedException">.NET Core only: In all cases.</exception>
27052721
</Docs>
27062722
</Member>
27072723
<Member MemberName="Import">
@@ -2764,6 +2780,7 @@
27642780
]]></format>
27652781
</remarks>
27662782
<exception cref="T:System.ArgumentException">The <paramref name="fileName" /> parameter is <see langword="null" />.</exception>
2783+
<exception cref="T:System.PlatformNotSupportedException">.NET Core only: In all cases.</exception>
27672784
<permission cref="T:System.Security.SecurityCriticalAttribute">requires full trust for the immediate caller. This class cannot be used by partially trusted or transparent code.</permission>
27682785
<permission cref="F:System.Security.Permissions.SecurityAction.InheritanceDemand">for full trust for inheritors. This member cannot be inherited by partially trusted code.</permission>
27692786
<permission cref="T:System.Security.Permissions.FileIOPermission">for permission to read the file described by the <paramref name="fileName" /> parameter. Security action: <see cref="F:System.Security.Permissions.SecurityAction.Demand" />. Associated enumeration: <see cref="F:System.Security.Permissions.EnvironmentPermissionAccess.Read" /></permission>
@@ -2831,6 +2848,7 @@
28312848
-or-
28322849

28332850
The length of the <paramref name="rawData" /> parameter is 0.</exception>
2851+
<exception cref="T:System.PlatformNotSupportedException">.NET Core only: In all cases.</exception>
28342852
<permission cref="T:System.Security.SecurityCriticalAttribute">requires full trust for the immediate caller. This class cannot be used by partially trusted or transparent code.</permission>
28352853
<permission cref="F:System.Security.Permissions.SecurityAction.InheritanceDemand">for full trust for inheritors. This member cannot be inherited by partially trusted code.</permission>
28362854
<permission cref="T:System.Security.Permissions.KeyContainerPermission">for permission to create a key container. Security action: <see cref="F:System.Security.Permissions.SecurityAction.Demand" />. Associated enumeration: <see cref="F:System.Security.Permissions.KeyContainerPermissionFlags.Create" /></permission>
@@ -2895,6 +2913,7 @@
28952913
-or-
28962914

28972915
The length of the <paramref name="rawData" /> parameter is 0.</exception>
2916+
<exception cref="T:System.PlatformNotSupportedException">.NET Core only: In all cases.</exception>
28982917
<permission cref="T:System.Security.SecurityCriticalAttribute">requires full trust for the immediate caller. This class cannot be used by partially trusted or transparent code.</permission>
28992918
<permission cref="F:System.Security.Permissions.SecurityAction.InheritanceDemand">for full trust for inheritors. This member cannot be inherited by partially trusted code.</permission>
29002919
<permission cref="T:System.Security.Permissions.KeyContainerPermission">for permission to create a key container. Security action: <see cref="F:System.Security.Permissions.SecurityAction.Demand" />. Associated enumeration: <see cref="F:System.Security.Permissions.KeyContainerPermissionFlags.Create" /></permission>
@@ -2957,6 +2976,7 @@
29572976
]]></format>
29582977
</remarks>
29592978
<exception cref="T:System.ArgumentException">The <paramref name="fileName" /> parameter is <see langword="null" />.</exception>
2979+
<exception cref="T:System.PlatformNotSupportedException">.NET Core only: In all cases.</exception>
29602980
<permission cref="T:System.Security.SecurityCriticalAttribute">requires full trust for the immediate caller. This class cannot be used by partially trusted or transparent code.</permission>
29612981
<permission cref="F:System.Security.Permissions.SecurityAction.InheritanceDemand">for full trust for inheritors. This member cannot be inherited by partially trusted code.</permission>
29622982
<permission cref="T:System.Security.Permissions.FileIOPermission">for permission to read the file described by the <paramref name="fileName" /> parameter. Security action: <see cref="F:System.Security.Permissions.SecurityAction.Demand" />. Associated enumeration: <see cref="F:System.Security.Permissions.EnvironmentPermissionAccess.Read" /></permission>
@@ -3020,6 +3040,7 @@
30203040
]]></format>
30213041
</remarks>
30223042
<exception cref="T:System.ArgumentException">The <paramref name="fileName" /> parameter is <see langword="null" />.</exception>
3043+
<exception cref="T:System.PlatformNotSupportedException">.NET Core only: In all cases.</exception>
30233044
<permission cref="T:System.Security.SecurityCriticalAttribute">requires full trust for the immediate caller. This class cannot be used by partially trusted or transparent code.</permission>
30243045
<permission cref="F:System.Security.Permissions.SecurityAction.InheritanceDemand">for full trust for inheritors. This member cannot be inherited by partially trusted code.</permission>
30253046
<permission cref="T:System.Security.Permissions.FileIOPermission">for permission to read the file described by the <paramref name="fileName" /> parameter. Security action: <see cref="F:System.Security.Permissions.SecurityAction.Demand" />. Associated enumeration: <see cref="F:System.Security.Permissions.EnvironmentPermissionAccess.Read" /></permission>
@@ -3198,6 +3219,7 @@
31983219
<param name="sender">The source of the deserialization event.</param>
31993220
<summary>Implements the <see cref="T:System.Runtime.Serialization.ISerializable" /> interface and is called back by the deserialization event when deserialization is complete.</summary>
32003221
<remarks>To be added.</remarks>
3222+
<exception cref="T:System.PlatformNotSupportedException">.NET Core only: In all cases.</exception>
32013223
</Docs>
32023224
</Member>
32033225
<Member MemberName="System.Runtime.Serialization.ISerializable.GetObjectData">
@@ -3244,6 +3266,7 @@
32443266
<param name="context">The destination context of the serialization.</param>
32453267
<summary>Gets serialization information with all the data needed to recreate an instance of the current <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> object.</summary>
32463268
<remarks>To be added.</remarks>
3269+
<exception cref="T:System.PlatformNotSupportedException">.NET Core only: In all cases.</exception>
32473270
<permission cref="T:System.Security.SecurityCriticalAttribute">requires full trust for the immediate caller. This member cannot be used by partially trusted or transparent code.</permission>
32483271
</Docs>
32493272
</Member>
@@ -3394,12 +3417,18 @@
33943417
<Parameter Name="bytesWritten" Type="System.Int32" RefType="out" Index="2" FrameworkAlternate="netcore-2.1;netcore-2.2;netcore-3.0;netstandard-2.1;netcore-3.1" />
33953418
</Parameters>
33963419
<Docs>
3397-
<param name="hashAlgorithm">To be added.</param>
3398-
<param name="destination">To be added.</param>
3399-
<param name="bytesWritten">To be added.</param>
3400-
<summary>To be added.</summary>
3401-
<returns>To be added.</returns>
3420+
<param name="hashAlgorithm">The algorithm to use for the thumbprint.</param>
3421+
<param name="destination">The buffer to receive the certificate thumbprint.</param>
3422+
<param name="bytesWritten">When this method returns, the total number of bytes written into <paramref name="destination"/>. This parameter is treated as uninitialized.</param>
3423+
<summary>Attempts to produce a "thumbprint" for the certificate by hashing the encoded representation of the certificate with the specified hash algorithm.</summary>
3424+
<returns>
3425+
<see langword="true"/> if <paramref name="destination"/> is long enough to receive the hash value; otherwise, <see langword="false"/>.</returns>
34023426
<remarks>To be added.</remarks>
3427+
<exception cref="T:System.ArgumentException">
3428+
<paramref name="hashAlgorithm" />.<see cref="P:System.Security.Cryptography.HashAlgorithmName.Name" /> is <see langword="null" /> or an empty string.</exception>
3429+
<exception cref="T:System.Security.Cryptography.CryptographicException">
3430+
<paramref name="hashAlgorithm" /> is not a known hash algorithm.</exception>
3431+
<altmember cref="M:System.Security.Cryptography.X509Certificates.X509Certificate.GetCertHash(System.Security.Cryptography.HashAlgorithmName)" />
34033432
</Docs>
34043433
</Member>
34053434
</Members>

xml/System.Security.Cryptography.X509Certificates/X509Certificate2.xml

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -934,11 +934,26 @@
934934
<Parameter Name="password" Type="System.String" Index="1" FrameworkAlternate="xamarinandroid-7.1;xamarinios-10.8;xamarinmac-3.0" />
935935
</Parameters>
936936
<Docs>
937-
<param name="contentType">To be added.</param>
938-
<param name="password">To be added.</param>
939-
<summary>To be added.</summary>
940-
<returns>To be added.</returns>
941-
<remarks>To be added.</remarks>
937+
<param name="contentType">One of the <see cref="T:System.Security.Cryptography.X509Certificates.X509ContentType" /> values that describes how to format the output data.</param>
938+
<param name="password">The password required to access the X.509 certificate data.</param>
939+
<summary>Exports the current <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> object to a byte array in a format described by one of the <see cref="T:System.Security.Cryptography.X509Certificates.X509ContentType" /> values, and using the specified password.</summary>
940+
<returns>An array of bytes that represents the current <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> object.</returns>
941+
<remarks>
942+
<format type="text/markdown"><![CDATA[
943+
944+
## Remarks
945+
The `contentType` parameter accepts only the following values of the <xref:System.Security.Cryptography.X509Certificates.X509ContentType> enumeration: <xref:System.Security.Cryptography.X509Certificates.X509ContentType.Cert>, <xref:System.Security.Cryptography.X509Certificates.X509ContentType.SerializedCert>, and <xref:System.Security.Cryptography.X509Certificates.X509ContentType.Pkcs12>. Passing any other value causes a <xref:System.Security.Cryptography.CryptographicException> to be thrown.
946+
947+
> [!IMPORTANT]
948+
> Never hard code a password within your source code. Hard-coded passwords can be retrieved from an assembly using the [Ildasm.exe (IL Disassembler)](~/docs/framework/tools/ildasm-exe-il-disassembler.md) tool, a hex editor, or by simply opening the assembly in a text editor such as Notepad.exe.
949+
950+
]]></format>
951+
</remarks>
952+
<exception cref="T:System.Security.Cryptography.CryptographicException">A value other than <see cref="F:System.Security.Cryptography.X509Certificates.X509ContentType.Cert" />, <see cref="F:System.Security.Cryptography.X509Certificates.X509ContentType.SerializedCert" />, or <see cref="F:System.Security.Cryptography.X509Certificates.X509ContentType.Pkcs12" /> was passed to the <paramref name="contentType" /> parameter.
953+
954+
-or-
955+
956+
The certificate could not be exported.</exception>
942957
</Docs>
943958
</Member>
944959
<Member MemberName="Extensions">

0 commit comments

Comments
 (0)