File tree Expand file tree Collapse file tree 2 files changed +15
-4
lines changed
generator/cybersource-csharp-template Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change 2424using AuthenticationSdk . util ;
2525using System . Security . Cryptography . X509Certificates ;
2626using NLog ;
27+ using System . Security ;
2728
2829namespace CyberSource . Client
2930{
@@ -456,11 +457,16 @@ public object CallApi(
456457 {
457458 string clientCertDirectory = Configuration . MerchantConfigDictionaryObj [ "clientCertDirectory" ] ;
458459 string clientCertFile = Configuration . MerchantConfigDictionaryObj [ "clientCertFile" ] ;
459- string clientCertPassword = Configuration . MerchantConfigDictionaryObj [ "clientCertPassword" ] ;
460+ SecureString clientCertPassword = new SecureString ( ) ;
461+ foreach ( char c in Configuration . MerchantConfigDictionaryObj [ "clientCertPassword" ] )
462+ {
463+ clientCertPassword . AppendChar ( c ) ;
464+ }
465+ clientCertPassword . MakeReadOnly ( ) ;
460466 string fileName = Path . Combine ( clientCertDirectory , clientCertFile ) ;
461467 // Importing Certificates
462468 var certificate = new X509Certificate2 ( fileName , clientCertPassword ) ;
463- clientCertPassword = string . Empty ;
469+ clientCertPassword . Dispose ( ) ;
464470 RestClient . Options . ClientCertificates = new X509CertificateCollection { certificate } ;
465471 }
466472
Original file line number Diff line number Diff line change @@ -498,11 +498,16 @@ namespace {{packageName}}.Client
498498 {
499499 string clientCertDirectory = Configuration.MerchantConfigDictionaryObj[" clientCertDirectory" ];
500500 string clientCertFile = Configuration.MerchantConfigDictionaryObj[" clientCertFile" ];
501- string clientCertPassword = Configuration.MerchantConfigDictionaryObj[" clientCertPassword" ];
501+ SecureString clientCertPassword = new SecureString();
502+ foreach (char c in Configuration.MerchantConfigDictionaryObj[" clientCertPassword" ])
503+ {
504+ clientCertPassword.AppendChar(c);
505+ }
506+ clientCertPassword.MakeReadOnly();
502507 string fileName = Path.Combine(clientCertDirectory, clientCertFile);
503508 // Importing Certificates
504509 var certificate = new X509Certificate2(fileName, clientCertPassword);
505- clientCertPassword= string.Empty ;
510+ clientCertPassword.Dispose() ;
506511 RestClient.Options.ClientCertificates = new X509CertificateCollection { certificate } ;
507512 }
508513
You can’t perform that action at this time.
0 commit comments