Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 3 additions & 5 deletions nanoFramework.System.Net/X509Certificates/X509Certificate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// See LICENSE file in the project root for full license information.
//

namespace System.Security.Cryptography.X509Certificates
namespace System.Security.Cryptography.X509Certificates
{
using System;
using System.Runtime.CompilerServices;
Expand Down Expand Up @@ -61,7 +61,7 @@ public X509Certificate()
/// ASN.1 DER is the only certificate format supported by this class.
/// </remarks>
public X509Certificate(byte[] certificate)
: this(certificate, "")
: this(certificate, null)
{
}

Expand All @@ -76,7 +76,7 @@ public X509Certificate(byte[] certificate)
public X509Certificate(byte[] certificate, string password)
{
_certificate = certificate;
_password = password;
_password = password;

ParseCertificate(certificate, password, ref _issuer, ref _subject, ref _effectiveDate, ref _expirationDate);
}
Expand All @@ -101,8 +101,6 @@ public X509Certificate(string certificate)
Array.Copy(tempCertificate, _certificate, tempCertificate.Length);
_certificate[_certificate.Length - 1] = 0;

_password = "";

ParseCertificate(_certificate, _password, ref _issuer, ref _subject, ref _effectiveDate, ref _expirationDate);
}

Expand Down
38 changes: 27 additions & 11 deletions nanoFramework.System.Net/X509Certificates/X509Certificate2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace System.Security.Cryptography.X509Certificates
public class X509Certificate2 : X509Certificate
{
#pragma warning disable S3459 // Unassigned members should be removed
// these fields are required and set in native code
// field required to be accessible by native code
private readonly byte[] _privateKey;
#pragma warning restore S3459 // Unassigned members should be removed

Expand All @@ -25,6 +25,7 @@ public class X509Certificate2 : X509Certificate
public X509Certificate2()
: base()
{

}

/// <summary>
Expand Down Expand Up @@ -75,14 +76,19 @@ public X509Certificate2(string certificate, string password)
/// <summary>
/// Initializes a new instance of the <see cref="X509Certificate2"/> class using a string with the content of an X.509 public certificate, the private key and a password used to access the certificate.
/// </summary>
/// <param name="certificate">A string containing a X.509 certificate.</param>
/// <param name="rawData">A string containing a X.509 certificate.</param>
/// <param name="key">A string containing a PEM private key.</param>
/// <param name="password">The password required to access the X.509 certificate data.</param>
/// <param name="password">The password required to access the X.509 certificate data. Set to <see langword="null"/> if the <paramref name="rawData"/> or <paramref name="key"/> are not encrypted and do not require a password.</param>
/// <remarks>
/// This methods is exclusive of nanoFramework. There is no equivalent in .NET framework.
/// </remarks>
public X509Certificate2(string certificate, string key, string password)
: base(certificate, password)
public X509Certificate2(
string rawData,
string key,
string password)
: base(
rawData,
password)
{
var tempKey = Encoding.UTF8.GetBytes(key);

Expand All @@ -104,12 +110,17 @@ public X509Certificate2(string certificate, string key, string password)
/// </summary>
/// <param name="rawData">A byte array containing data from an X.509 certificate.</param>
/// <param name="key">A string containing a PEM private key.</param>
/// <param name="password">The password required to access the X.509 certificate data.</param>
/// <param name="password">The password required to access the X.509 certificate data. Set to <see langword="null"/> if the <paramref name="rawData"/> or <paramref name="key"/> are not encrypted and do not require a password.</param>
/// <remarks>
/// This methods is exclusive of nanoFramework. There is no equivalent in .NET framework.
/// </remarks>
public X509Certificate2(byte[] rawData, string key, string password)
: base(rawData, password)
public X509Certificate2(
byte[] rawData,
string key,
string password)
: base(
rawData,
password)
{
var tempKey = Encoding.UTF8.GetBytes(key);

Expand All @@ -131,12 +142,17 @@ public X509Certificate2(byte[] rawData, string key, string password)
/// </summary>
/// <param name="rawData">A byte array containing data from an X.509 certificate.</param>
/// <param name="key">A byte array containing a PEM private key.</param>
/// <param name="password">The password required to access the X.509 certificate data.</param>
/// <param name="password">The password required to access the X.509 certificate data. <see langword="null"/> if the <paramref name="rawData"/> or <paramref name="key"/> are not encrypted.</param>
/// <remarks>
/// This methods is exclusive of nanoFramework. There is no equivalent in .NET framework.
/// </remarks>
public X509Certificate2(byte[] rawData, byte[] key, string password)
: base(rawData, password)
public X509Certificate2(
byte[] rawData,
byte[] key,
string password)
: base(
rawData,
password)
{
_privateKey = key;

Expand Down