maythamfahmi / CryptoNet

CryptoNet is simple, fast and a lightweight asymmetric and symmetric encryption library.
https://github.com/maythamfahmi/CryptoNet
MIT License
101 stars 19 forks source link

[Bug]: Windows ci pipeline breaks #110

Closed maythamfahmi closed 1 month ago

maythamfahmi commented 1 month ago

Contact Details

No response

What happened?

When running windows ci pipeline, it breaks

Reference: https://github.com/maythamfahmi/CryptoNet/actions/runs/11418047460/job/31771023350

Version

3.0.x >= (Coming soon)

What Operating System are you seeing the problem on?

Windows

Relevant log output

Test run for D:\a\CryptoNet\CryptoNet\CryptoNet.UnitTests\bin\Release\net8.0\CryptoNet.UnitTests.dll (.NETCoreApp,Version=v8.0)
Test run for D:\a\CryptoNet\CryptoNet\Examples\Examples.UnitTests\bin\Release\net8.0\Examples.UnitTests.dll (.NETCoreApp,Version=v8.0)
VSTest version 17.11.1 (x64)
VSTest version 17.11.1 (x64)

Starting test execution, please wait...
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
A total of 1 test files matched the specified pattern.

Passed!  - Failed:     0, Passed:     2, Skipped:     0, Total:     2, Duration: 1 s - Examples.UnitTests.dll (net8.0)
  Failed Encrypt_With_PublicKey_Decrypt_With_PrivateKey_Of_Content_Test [5 ms]
  Error Message:
   System.IO.FileNotFoundException : Could not find file 'D:\a\CryptoNet\CryptoNet\CryptoNet.UnitTests\bin\Release\net8.0\publicKey.pub'.
  Stack Trace:
     at Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
   at System.IO.File.ReadAllBytes(String path)
   at CryptoNet.Utils.CryptoNetUtils.LoadFileToBytes(String filename) in /_/CryptoNet/Utils/CryptoNetUtils.cs:line 20
   at CryptoNet.Utils.CryptoNetUtils.LoadFileToString(String filename) in /_/CryptoNet/Utils/CryptoNetUtils.cs:line 25
   at CryptoNet.CryptoNetRsa..ctor(FileInfo fileInfo, Int32 keySize) in /_/CryptoNet/CryptoNetRsa.cs:line 53
   at CryptoNet.UnitTests.CryptoNetRsaTests.Encrypt_With_PublicKey_Decrypt_With_PrivateKey_Of_Content_Test() in {CryptoNet}/CryptoNet.UnitTests/CryptoNetRsaTests.cs:line 193
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)

  Failed Export_Public_Key_For_X509_Certificate_Test [34 ms]
  Error Message:
   System.ArgumentNullException : Value cannot be null. (Parameter 'certificate')
  Stack Trace:
     at System.ArgumentNullException.Throw(String paramName)
   at System.ArgumentNullException.ThrowIfNull(Object argument, String paramName)
   at System.Security.Cryptography.X509Certificates.CertificateExtensionsCommon.GetPrivateKey[T](X509Certificate2 certificate, Predicate`1 matchesConstraints)
   at CryptoNet.Extensions.CryptoNetExtensions.GetParameters(X509Certificate2 certificate, KeyType keyType) in /_/CryptoNet.Extensions/CryptoNetExtensions.cs:line 20
   at CryptoNet.CryptoNetRsa..ctor(X509Certificate2 certificate, KeyType keyType, Int32 keySize) in /_/CryptoNet/CryptoNetRsa.cs:line 68
   at CryptoNet.UnitTests.CryptoNetRsaTests.Export_Public_Key_For_X509_Certificate_Test() in {CryptoNet}/CryptoNet.UnitTests/CryptoNetRsaTests.cs:line 225
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)

Failed!  - Failed:     2, Passed:    32, Skipped:     0, Total:    34, Duration: 2 s - CryptoNet.UnitTests.dll (net8.0)

Workload updates are available. Run `dotnet workload list` for more information.

Code of Conduct

maythamfahmi commented 1 month ago

Fixed #111