File tree Expand file tree Collapse file tree
modules/openapi-generator/src/main/resources/csharp
samples/client/petstore/csharp
OpenAPIClient-ConditionalSerialization/src/Org.OpenAPITools/Client
OpenAPIClient-httpclient/src/Org.OpenAPITools/Client
OpenAPIClient-net47/src/Org.OpenAPITools/Client
OpenAPIClient-net48/src/Org.OpenAPITools/Client
OpenAPIClient-net5.0/src/Org.OpenAPITools/Client
OpenAPIClient-unityWebRequest/src/Org.OpenAPITools/Client
OpenAPIClientCore/src/Org.OpenAPITools/Client
OpenAPIClient/src/Org.OpenAPITools/Client Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -373,8 +373,7 @@ namespace {{packageName}}.Client
373373 else
374374 ecdsa.ImportPkcs8PrivateKey(keyBytes, out byteCount);
375375
376- var signedBytes = ecdsa.SignHash(dataToSign);
377- var derBytes = ConvertToECDSAANS1Format(signedBytes);
376+ var derBytes = ecdsa.SignHash(dataToSign, DSASignatureFormat.Rfc3279DerSequence);
378377 var signedString = System.Convert.ToBase64String(derBytes);
379378
380379 return signedString;
@@ -384,6 +383,11 @@ namespace {{packageName}}.Client
384383 { {/net60OrLater} }
385384 }
386385
386+ /// <summary >
387+ /// Convert ANS1 format to DER format. Not recommended to use because it generate inavlid signature occationally.
388+ /// </summary >
389+ /// <param name =" signedBytes" ></param >
390+ /// <returns ></returns >
387391 private byte[] ConvertToECDSAANS1Format(byte[] signedBytes)
388392 {
389393 var derBytes = new List< byte> ();
Original file line number Diff line number Diff line change @@ -352,6 +352,11 @@ private string GetECDSASignature(byte[] dataToSign)
352352 throw new Exception ( "ECDSA signing is supported only on NETCOREAPP3_0 and above" ) ;
353353 }
354354
355+ /// <summary>
356+ /// Convert ANS1 format to DER format. Not recommended to use because it generate inavlid signature occationally.
357+ /// </summary>
358+ /// <param name="signedBytes"></param>
359+ /// <returns></returns>
355360 private byte [ ] ConvertToECDSAANS1Format ( byte [ ] signedBytes )
356361 {
357362 var derBytes = new List < byte > ( ) ;
Original file line number Diff line number Diff line change @@ -352,6 +352,11 @@ private string GetECDSASignature(byte[] dataToSign)
352352 throw new Exception ( "ECDSA signing is supported only on NETCOREAPP3_0 and above" ) ;
353353 }
354354
355+ /// <summary>
356+ /// Convert ANS1 format to DER format. Not recommended to use because it generate inavlid signature occationally.
357+ /// </summary>
358+ /// <param name="signedBytes"></param>
359+ /// <returns></returns>
355360 private byte [ ] ConvertToECDSAANS1Format ( byte [ ] signedBytes )
356361 {
357362 var derBytes = new List < byte > ( ) ;
Original file line number Diff line number Diff line change @@ -352,6 +352,11 @@ private string GetECDSASignature(byte[] dataToSign)
352352 throw new Exception ( "ECDSA signing is supported only on NETCOREAPP3_0 and above" ) ;
353353 }
354354
355+ /// <summary>
356+ /// Convert ANS1 format to DER format. Not recommended to use because it generate inavlid signature occationally.
357+ /// </summary>
358+ /// <param name="signedBytes"></param>
359+ /// <returns></returns>
355360 private byte [ ] ConvertToECDSAANS1Format ( byte [ ] signedBytes )
356361 {
357362 var derBytes = new List < byte > ( ) ;
Original file line number Diff line number Diff line change @@ -352,6 +352,11 @@ private string GetECDSASignature(byte[] dataToSign)
352352 throw new Exception ( "ECDSA signing is supported only on NETCOREAPP3_0 and above" ) ;
353353 }
354354
355+ /// <summary>
356+ /// Convert ANS1 format to DER format. Not recommended to use because it generate inavlid signature occationally.
357+ /// </summary>
358+ /// <param name="signedBytes"></param>
359+ /// <returns></returns>
355360 private byte [ ] ConvertToECDSAANS1Format ( byte [ ] signedBytes )
356361 {
357362 var derBytes = new List < byte > ( ) ;
Original file line number Diff line number Diff line change @@ -380,13 +380,17 @@ private string GetECDSASignature(byte[] dataToSign)
380380 else
381381 ecdsa . ImportPkcs8PrivateKey ( keyBytes , out byteCount ) ;
382382
383- var signedBytes = ecdsa . SignHash ( dataToSign ) ;
384- var derBytes = ConvertToECDSAANS1Format ( signedBytes ) ;
383+ var derBytes = ecdsa . SignHash ( dataToSign , DSASignatureFormat . Rfc3279DerSequence ) ;
385384 var signedString = System . Convert . ToBase64String ( derBytes ) ;
386385
387386 return signedString ;
388387 }
389388
389+ /// <summary>
390+ /// Convert ANS1 format to DER format. Not recommended to use because it generate inavlid signature occationally.
391+ /// </summary>
392+ /// <param name="signedBytes"></param>
393+ /// <returns></returns>
390394 private byte [ ] ConvertToECDSAANS1Format ( byte [ ] signedBytes )
391395 {
392396 var derBytes = new List < byte > ( ) ;
Original file line number Diff line number Diff line change @@ -352,6 +352,11 @@ private string GetECDSASignature(byte[] dataToSign)
352352 throw new Exception ( "ECDSA signing is supported only on NETCOREAPP3_0 and above" ) ;
353353 }
354354
355+ /// <summary>
356+ /// Convert ANS1 format to DER format. Not recommended to use because it generate inavlid signature occationally.
357+ /// </summary>
358+ /// <param name="signedBytes"></param>
359+ /// <returns></returns>
355360 private byte [ ] ConvertToECDSAANS1Format ( byte [ ] signedBytes )
356361 {
357362 var derBytes = new List < byte > ( ) ;
Original file line number Diff line number Diff line change @@ -352,6 +352,11 @@ private string GetECDSASignature(byte[] dataToSign)
352352 throw new Exception ( "ECDSA signing is supported only on NETCOREAPP3_0 and above" ) ;
353353 }
354354
355+ /// <summary>
356+ /// Convert ANS1 format to DER format. Not recommended to use because it generate inavlid signature occationally.
357+ /// </summary>
358+ /// <param name="signedBytes"></param>
359+ /// <returns></returns>
355360 private byte [ ] ConvertToECDSAANS1Format ( byte [ ] signedBytes )
356361 {
357362 var derBytes = new List < byte > ( ) ;
Original file line number Diff line number Diff line change @@ -380,13 +380,17 @@ private string GetECDSASignature(byte[] dataToSign)
380380 else
381381 ecdsa . ImportPkcs8PrivateKey ( keyBytes , out byteCount ) ;
382382
383- var signedBytes = ecdsa . SignHash ( dataToSign ) ;
384- var derBytes = ConvertToECDSAANS1Format ( signedBytes ) ;
383+ var derBytes = ecdsa . SignHash ( dataToSign , DSASignatureFormat . Rfc3279DerSequence ) ;
385384 var signedString = System . Convert . ToBase64String ( derBytes ) ;
386385
387386 return signedString ;
388387 }
389388
389+ /// <summary>
390+ /// Convert ANS1 format to DER format. Not recommended to use because it generate inavlid signature occationally.
391+ /// </summary>
392+ /// <param name="signedBytes"></param>
393+ /// <returns></returns>
390394 private byte [ ] ConvertToECDSAANS1Format ( byte [ ] signedBytes )
391395 {
392396 var derBytes = new List < byte > ( ) ;
You can’t perform that action at this time.
0 commit comments