Skip to content

Commit

Permalink
Removed unreachable code (OPCFoundation#2916)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrsuciu authored Dec 19, 2024
1 parent 5e11541 commit 6489c12
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 32 deletions.
2 changes: 1 addition & 1 deletion Libraries/Opc.Ua.PubSub/Encoding/UadpNetworkMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public UadpNetworkMessage(UADPNetworkMessageDiscoveryType discoveryType)
/// Create new instance of <see cref="UadpNetworkMessage"/> as a DiscoveryResponse of PublisherEndpoints type
/// </summary>
/// <param name="publisherEndpoints"></param>
/// <param name="publisherProvidesEndpoints "></param>
/// <param name="publisherProvidesEndpoints"></param>
public UadpNetworkMessage(EndpointDescription[] publisherEndpoints, StatusCode publisherProvidesEndpoints)
: base(null, new List<UaDataSetMessage>())
{
Expand Down
19 changes: 0 additions & 19 deletions Stack/Opc.Ua.Core/Security/Certificates/CertificateIdentifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Text;
Expand Down Expand Up @@ -243,20 +241,6 @@ public async Task<X509Certificate2> Find(bool needPrivateKey)
return certificate;
}

/// <summary>
/// Updates the object from another object (usage is not updated).
/// </summary>
/// <param name="certificate">The certificate.</param>
private void Paste(CertificateIdentifier certificate)
{
this.SubjectName = certificate.SubjectName;
this.Thumbprint = certificate.Thumbprint;
this.RawData = certificate.RawData;
this.ValidationOptions = certificate.ValidationOptions;
this.Certificate = certificate.Certificate;
this.CertificateType = certificate.CertificateType;
}

/// <summary>
/// Returns a display name for a certificate.
/// </summary>
Expand Down Expand Up @@ -528,9 +512,6 @@ public ushort GetMinKeySize(SecurityConfiguration securityConfiguration)
// non RSA
return 0;
}

throw new ArgumentException("Certificate type is unknown");

}


Expand Down
16 changes: 9 additions & 7 deletions Stack/Opc.Ua.Core/Security/Certificates/EccUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,7 @@ public static string GetECDsaQualifier(X509Certificate2 certificate)
/// <returns></returns>
public static ECDsa GetPublicKey(X509Certificate2 certificate)
{
string[] securityPolicyUris;
return GetPublicKey(certificate, out securityPolicyUris);
return GetPublicKey(certificate, out string[] _);
}

/// <summary>
Expand All @@ -195,14 +194,19 @@ public static ECDsa GetPublicKey(X509Certificate2 certificate, out string[] secu
{
securityPolicyUris = null;

if (certificate == null)
{
return null;
}

var keyAlgorithm = certificate.GetKeyAlgorithm();

if (certificate == null || keyAlgorithm != Oids.ECPublicKey)
if (keyAlgorithm != Oids.ECPublicKey)
{
return null;
}

const X509KeyUsageFlags SufficientFlags =
const X509KeyUsageFlags kSufficientFlags =
X509KeyUsageFlags.KeyAgreement |
X509KeyUsageFlags.DigitalSignature |
X509KeyUsageFlags.NonRepudiation |
Expand All @@ -215,7 +219,7 @@ public static ECDsa GetPublicKey(X509Certificate2 certificate, out string[] secu
{
X509KeyUsageExtension kuExt = (X509KeyUsageExtension)extension;

if ((kuExt.KeyUsages & SufficientFlags) == 0)
if ((kuExt.KeyUsages & kSufficientFlags) == 0)
{
return null;
}
Expand Down Expand Up @@ -302,8 +306,6 @@ public static int GetSignatureLength(X509Certificate2 signingCertificate)

return publicKey.KeySize / 4;
}

throw new NotImplementedException();
}

/// <summary>
Expand Down
5 changes: 0 additions & 5 deletions Stack/Opc.Ua.Core/Security/Constants/SecurityPolicies.cs
Original file line number Diff line number Diff line change
Expand Up @@ -621,11 +621,6 @@ public static bool Verify(X509Certificate2 certificate, string securityPolicyUri
securityPolicyUri);
}
}

throw ServiceResultException.Create(
StatusCodes.BadSecurityChecksFailed,
"Unexpected security policy Uri: {0}",
securityPolicyUri);
}
#endregion
}
Expand Down

0 comments on commit 6489c12

Please sign in to comment.