Skip to content

Commit acf2cbd

Browse files
committed
fix(certificado): remove warning substituindo PrivateKey por GetRSAPrivateKey()
1 parent e696661 commit acf2cbd

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

DFe.Utils/Assinatura/AssinaturaDigital.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public static SignatureZeus Assina<T>(T objeto, string id, X509Certificate2 cert
5757
? FuncoesXml.ClasseParaXmlString(objetoLocal).RemoverAcentos()
5858
: FuncoesXml.ClasseParaXmlString(objetoLocal));
5959

60-
var docXml = new SignedXml(documento) { SigningKey = certificado.PrivateKey };
60+
var docXml = new SignedXml(documento) { SigningKey = certificado.GetRSAPrivateKey() };
6161

6262
docXml.SignedInfo.SignatureMethod = signatureMethod;
6363
var reference = new Reference { Uri = "#" + id, DigestMethod = digestMethod };

DFe.Utils/Assinatura/CertificadoDigital.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ private static void DefinirPinParaChavePrivada(this X509Certificate2 certificado
153153
if (Environment.OSVersion.Platform == PlatformID.Win32NT || Environment.OSVersion.Platform == PlatformID.Win32Windows || Environment.OSVersion.Platform == PlatformID.Win32S)
154154
{
155155
if (certificado == null) throw new ArgumentNullException("certificado");
156-
var key = (RSACryptoServiceProvider)certificado.PrivateKey;
156+
var key = (RSACryptoServiceProvider)certificado.GetRSAPrivateKey();
157157

158158
var providerHandle = IntPtr.Zero;
159159
var pinBuffer = Encoding.ASCII.GetBytes(pin);
@@ -338,7 +338,7 @@ public static bool IsA3(this X509Certificate2 x509Certificate2)
338338

339339
try
340340
{
341-
RSACryptoServiceProvider service = x509Certificate2.PrivateKey as RSACryptoServiceProvider;
341+
RSACryptoServiceProvider service = x509Certificate2.GetRSAPrivateKey() as RSACryptoServiceProvider;
342342

343343
if (service != null)
344344
{

NFe.Utils/Assinatura/Assinador.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public static Signature ObterAssinatura<T>(T objeto, string id, X509Certificate2
9797

9898
documento.LoadXml(xml);
9999

100-
var docXml = new SignedXml(documento) { SigningKey = certificadoDigital.PrivateKey };
100+
var docXml = new SignedXml(documento) { SigningKey = certificadoDigital.GetRSAPrivateKey() };
101101

102102
docXml.SignedInfo.SignatureMethod = signatureMethod;
103103

0 commit comments

Comments
 (0)