1474 Commits

Author SHA1 Message Date
Wojciech Nagórski a314700e47 Microsoft.Bcl.AsyncInterfaces version >= 1.0.0 (#1334) 2024.0.0 2024-02-21 19:51:12 +01:00
Scott Xu b3ec023052 Add Closed event to ShellStream. (#1332)
* Add `Closed` event to `ShellStream`. Lib consumer could hook to this event to detect if channel is closed by server **in time**.

* handle `Closed` event on different thread. No need to block original thread.
2024-02-21 08:48:02 +01:00
Wojciech Nagórski 442f0a9706 2024.0.0 (#1330) 2024-02-20 21:29:53 +01:00
Jean-Sebastien Carle f8b3ef30fc Moved IDE0005 warning configuration. (#1329) 2024-02-20 21:25:42 +01:00
Jean-Sebastien Carle b47b35c19b Updated dependencies. (#1328)
* Updated dependencies.

* Reverted Microsoft.Bcl.AsyncInterfaces back to version 1.0.0.

Also added a note so we no longer try to upgrade it.

* Reverted back to Moq.

---------

Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com>
2024-02-20 21:19:24 +01:00
Jean-Sebastien Carle 4b9c3bf144 Limit TimeSpan timeouts to Int32 MaxValue (#1321)
* Added guard clauses to various timeouts to ensure they don't exceed an Int32 in milliseconds.

* Fixed guard clauses.

* Updated build tags.

* Added guard clauses to various timeouts to ensure they don't exceed an Int32 in milliseconds.

* Fixed tests.

* Added additional tests.

* Replaced NoWarn with .editorconfig setting

* Fixed references to parameter names.
2024-02-20 21:17:47 +01:00
Rob Hague 664595d30b Restore the write buffer to ShellStream (#1327)
* Restore Write/Flush tests

* Restore write buffer to ShellStream and painfully fix the mocks

---------

Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com>
2024-02-18 06:38:11 +01:00
Scott Xu 59a0f9030a Drop RIPEMD160 (#1324) 2024-02-18 05:20:57 +01:00
Rob Hague 06af2ec6c0 Fix a few issues with ShellStream (#1322)
* Fix a few issues with ShellStream

The main change is to replace the Queue<byte> with a byte[] and a couple of
variables which index the start and end of the data. The remainder is mainly
slightly more careful locking semantics.

It also implements Expect(string) separately so that it can work on the bytes
and skip a lot of encoding work (this is where I wish ShellStream derived from
StreamReader).

One possibly contentious point: in fixing the Write behaviour I chose to
remove the "outgoing" buffer and immediately send the data across the channel.
Write(string) and WriteLine(string) were already doing this, and I felt it
was better to change Write(byte[]) to match rather than changing the string
methods.

* Integrate expectSize (as "windowSize" parameter)

* Rename "windowSize" to "lookback"

---------

Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com>
2024-02-16 20:11:22 +01:00
Rob Hague 2b19eecc16 CI: remove install of net8.0 sdk on VS image (#1323)
It is installed on the image now: https://www.appveyor.com/docs/windows-images-software/#net-framework
2024-02-16 14:58:31 +01:00
Scott Xu 7cfe62b9f1 Support ETM (Encrypt-then-MAC) variants for HMAC (#1316)
* Support ETM (Encrypt-then-MAC) variants for HMAC

* Support ETM (Encrypt-then-MAC) variants for HMAC

* Remove `ETM` property from `HashInfo`

* Add support for HmacMd5Etm, HmacMd5_96_Etm, HmacSha1Etm and HmacSha1_96_Etm
Explicitly specify etm even if false

* Add Encrypt-then-MAC variants to README.md

* Add back empty span to prevent auto link

* Store ETM in `HashInfo`;
Change `HMAC Create[...]Hash()` to `HashAlgorithm Create[...]Hash(out bool isEncryptThenMAC)`
2024-02-16 13:24:54 +01:00
Jean-Sebastien Carle d07827b6c8 Fixed dequeuing of incoming queue (#1319)
* Fixed dequeuing of incoming queue.

* Adjusted return of Expect to make sure it returns the full incoming queue.
2024-02-13 19:16:41 +01:00
Jean-Sebastien Carle bcaf354ccb Significantly improve performance of ShellStream's Expect methods (#1207)
* Significantly improved performance and fixed bug with ShellStream's Expect methods.

* Fix whitespace.

* Fixed test.

* Improve ShellStream Expect

* Fixed typo.

* Doubled expectBuffer's default size and added a large expect test.

* Added guard clauses to ShellStream constructor and adjusted Common_CreateMoreChannelsThanMaxSessions test.

* Fixed XMLDoc spelling mistakes.

---------

Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com>
Co-authored-by: Wojciech Nagórski <wojciech.nagorski@intel.com>
2024-02-13 13:41:47 +01:00
Scott Xu 7d357e8203 No need to collect nuget packages in appveyor.yml as the packages are not generated when build (#1317)
* Update appveyor.yml

No nupkg nor snupkg is generated at this moment. We can add these 2 lines back later if we decide to generate nuget packages when build.

* Update appveyor.yml

---------

Co-authored-by: Rob Hague <rob.hague00@gmail.com>
2024-02-13 12:34:11 +01:00
Wojciech Nagórski 3bfac50ad0 Improve ShellStream Expect (#1315) 2024-02-11 23:06:25 +01:00
Wojciech Nagórski dec04f26e0 2023.0.2 version (#1314) 2024-02-11 20:15:11 +01:00
Rob Hague e23f381dea Add tests and benchmarks for ShellStream.Read and Expect (#1313)
Most of them are ignored because they fail.
2024-02-11 10:00:38 +01:00
Ferenc Vizkeleti 2d0e03b8ce Added SshCommand.InputStream to allow writing to stdin of SshCommand (#1293)
* Making all unit tests pass locally.
Excluded MD5 tests on net462 because I get System.InvalidOperationException: 'This implementation is not part of the Windows Platform FIPS validated cryptographic algorithms.'
SshdConfig: do not throw for "Include", just do nothing.
Modified failing dos2unix parameters in Dockerfile.TestServer.
Forceing LF line ending for key files used by integration tests, otherwise using them causes error.
SftpClientTest.Test_Sftp_Multiple_Async_Upload_And_Download_10Files_5MB_Each times out for maxFiles=10, decreasing to 2 to make the test pass.

* Added SshCommand.InputStream.

* Added an integration test for SshCommand.InputStream.

* Reverting changes made to unit tests unrelated to this PR.

* Moved ChannelInputStream's EOF sending from Write to Dispose. Replace SshCommand.InputStream with CreateInputStream to emphasise that a (disposable) resource is created here. EndExecute also closes the _inputStream to make sure that EOF is sent (in case the user forgot to dispose the input stream). Added more unit tests: sending the input one byte at a time, not disposing the input stream, calling CreateInputStream before BeginExecute or AfterEndExecute throws exception.

* Fixing review comments.

* Fix build error after #1286

---------

Co-authored-by: ferenc.vizkeleti <ferenc.vizkeleti@innopay.hu>
Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com>
Co-authored-by: Rob Hague <rob.hague00@gmail.com>
2024-02-06 18:02:19 +01:00
Rob Hague bfe6718fce Allow the integration tests to run on .NET Framework (#1286)
* Allow the integration tests to run on .NET Framework

* Update appveyor.yml

* Update appveyor.yml

---------

Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com>
2024-02-06 13:30:01 +01:00
Rob Hague 47eabe7574 Tweak semaphore usage in Session (#1304)
- Change _connectAndLazySemaphoreInitLock to a SemaphoreSlim and use it in
  ConnectAsync.
- Rename it to _connectLock and only use it for connecting. Replace its
  other usages (on SessionSemaphore and NextChannelNumber) with Interlocked
  operations.
- Remove AuthenticationConnection semaphore. This static member placed a
  process-wide limit on the number of connections an application can make.
  I agree with the argument in
  https://github.com/sshnet/SSH.NET/issues/409#issuecomment-457415542
  (and in several other issues/PRs) that this should not be something
  that the library attempts to control.

The last change broke a few tests which do things like making 100 connections.
I was tempted to delete these tests as I don't think they have much value, but
instead I just limited their concurrency.

Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com>
2024-02-06 13:16:11 +01:00
Rob Hague 54a001adea Use BinaryPrimitives in Pack (#1305) 2024-02-06 11:50:33 +01:00
Rob Hague 379e3ddc8a Update gitignore (#1261)
Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com>
2024-02-01 21:31:54 +01:00
Scott Xu 323b514be7 Merge nuspec and CommonAssemblyInfo into csproj (#1256)
* GeneratePackageOnBuild
IncludeSymbols

* Add packages to artifacts

* Update src/Renci.SshNet/Renci.SshNet.csproj

Co-authored-by: Rob Hague <rob.hague00@gmail.com>

* Update Renci.SshNet.csproj

Co-authored-by: Rob Hague <rob.hague00@gmail.com>

* Delete build/nuget/SSH.NET.nuspec

* Delete SSH.NET.nuspec from .sln file

* Update Renci.SshNet.csproj

* Update build.proj

---------

Co-authored-by: Rob Hague <rob.hague00@gmail.com>
2024-01-28 19:00:24 +01:00
Wojciech Nagórski 0371af9aaf Integration benchmark tests (#1298)
* Integration benchmark tests

* Fixes

* Write with encoding

* Update src/Renci.SshNet/Common/SshDataStream.cs

Co-authored-by: Rob Hague <rob.hague00@gmail.com>

* Add more benchmarks

---------

Co-authored-by: Rob Hague <rob.hague00@gmail.com>
2024-01-28 11:05:42 +01:00
Rob Hague 64b428f7bf Enable trim analysis and fix warnings (#1216)
* Enable trim analysis and fix warnings

* Use EnableTrimAnalyzer instead of IsTrimmable

I don't know how IsTrimmable works with references
(i.e. to SshNet.Security.Cryptography)

* Add additional aot/trimming related analyzers

* Initialise the hash instance in the constructor

---------

Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com>
2024-01-26 08:20:53 +01:00
Wojciech Nagórski 0a7ef46f0f Fix build script (#1295) 2024-01-25 21:31:14 +01:00
Jacob Slusser 48a8fe6502 Plumbing for more async/await work (#1281)
* Changes _socketDisposeLock to a SemaphoreSlim so it can play nice with async/await

* Adds a SendAsync method for .NET6+

* Fix false positive analyzer error

* Formatting

---------

Co-authored-by: Robert Hague <rh@johnstreetcapital.com>
Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com>
Co-authored-by: Rob Hague <rob.hague00@gmail.com>
2024-01-25 21:00:19 +01:00
mus65 13a6b5df0e Remove unneeded feature flags and pass cancellationToken to DNS request (#1290)
* remove unneeded feature flags

FEATURE_SOCKET_EAP and FEATURE_DNS_SYNC were set for all
frameworks, so unneeded. The other feature flags were
only used in elif of FEATURE_SOCKET_EAP and FEATURE_DNS_SYNC,
so also unneeded.

* pass cancellationToken to Dns.GetHostAddressesAsync

* Removed DnsAbstractions
2024-01-07 21:04:16 +01:00
mus65 765da9320e Require Microsoft.Bcl.AsyncInterfaces >=1.0.0 instead of =8.0.0 (#1288)
This technically fixes 2 different issues:
- previously SSH.NET would require exactly(!) version 8.0.0, which would
  cause issues in the future if e.g. a project using SSH.NET would
  try to update to version 9.0.0. In this case the constraint on the
  exact version would cause NuGet to refuse to upgrade to 9.0.0 (#1287)
- PowerShell Core seems to have problems with Version 8.0.0, therefore
  downgrade the requirement to 1.0.0 (see https://github.com/darkoperator/Posh-SSH/issues/558)

I had to re-enable AutoGenerateBindingRedirects, otherwise there is a
FileLoadException with net462 in one of the tests. I don't know why this
was disabled in 3ecbd1071d .
2024-01-05 22:13:06 +01:00
Wojciech Nagórski 7436a38b78 Remove code examples (#1210)
* Release 2023.0.0 (#1201)

* Assets/logos (#782)

* Added logo assets

* Added PNG 1260x640 with white border

Co-authored-by: 103filgualan <f.gualandi@crif.com>

* OPENSSH KeyReader for more keys (#614)

* OPENSSH KeyReader for more keys

Add support to parse OpenSSH Keys with ECDSA 256/384/521 and RSA.

https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.key

Change-Id: Iaa9cce0f2522e5fee377a82cb252f81f0b7cc563

* Fix ED25519Key KeyLength

* Fix ED25519 PubKey-auth

LeadingZeros of BigInteger-Conversion have to be removed
before sending the Key.

* Add interface to SftpFile #120 (#812)

* Create ISftpFile interface. SftpFile sealed. Return ISftpFile from SftpClient instead of SftpFile. Make ISftpClient interface disposable.

Co-authored-by: Wojciech Swieboda <wswieboda@chathamfinancial.com>

* Start MessageListener with ThreadAbstraction.ExecuteThreadLongRunning (#902)

* Fix Thread pool exhaustion due to MessageListener running on ThreadPool
* Mark long running thread as background

* Add async support to SftpClient and SftpFileStream (#819)

* Add FEATURE_TAP and net472 target
* Add TAP async support to SftpClient and SftpFileStream
* Add async support to DnsAbstraction and SocketAbstraction
* Add async support to *Connector and refactor the hierarchy
* Add ConnectAsync to BaseClient

* Add CODEOWNERS file.

* Fix virus false-positive by Defender on Renci.SSHNet.Tests.dll (#867)

Co-authored-by: Pedro Fonseca <pfonseca@qti.qualcomm.com>

* Add unit tests for task-based asynchronous API (#906)

* Fix runtime and culture dependant tests.
* Set C# 7.3 in Tests.csproj to limit intellisense's suggestions under different targets
* Add SftpClientTest.*Async
* Add SftpFileStreamTest_OpenAsync_*
* Add SftpFileStreamTest_WriteAsync_*
* Add SftpFileStreamTest_ReadAsync_*
* Align AppVeyor script with Test project target frameworks

* correct 'Documenation' to 'Documentation' (#838)

in the documentation's window title

* Agent auth and Keygen (#794)

* Allow to set PrivateKeyFile Key directly
   So you can add your own Key-Classes to SSH.NET
* Add ED25519 ctor for just pub key part.
* Make ECDSA Key Bits accessible
   You cant export imported CngKeys. To be able to export them to agent or Key-Files make the private bits also accessible.
* Better NETFRAMEWORK vs NETSTANDARD handling
* Add Comment Property to Key
* Add IPrivateKeySource
  So Extension can add own PrivateKeyFiles, e.g. PuttyKeyFile.

* Use cryptographically secure random number generator.
Fixes CVE-2022-29245.

* Remove unused import.

* Add IBaseClient for BaseClient and ISftpClient to inherit from (#975)

Add IBaseClient for BaseClient and ISftpClient to inherit from

* fix typo (#999)

* Fix Seek Operations in SftpFileStream (#910)

* Fix offset operations in SftpFileStream.Seek
* Fix seek exception message and add default case for invalid seek origin
* Use named params when throwing ArgumentException
* Add tests for seeking from end of file

* Add back copyright to license. (#1060)

Fixes #1059.

* Removing old target frameworks (#1109)

Remove support for legacy / deprecated target frameworks while adding support for .NET 6.0 (and higher).
The supported target frameworks are now:
* .NETFramework 4.6.2 (and higher)
* .NET Standard 2.0
* .NET 6.0 (and higher)

* Remove old features [Part 1] (#1117)

Remove obsolete feature switches (now that we've remove support for legacy target frameworks) and remove corresponding conditional code.

* Remove FEATURE_DIRECTORYINFO_ENUMERATEFILES (#1119)

* Remove FEATURE_DIRECTORYINFO_ENUMERATEFILES
* Add exception documentation

* Fix some (lots of) issues reported by analyzers. (#1125)

Fix some (lots of) issues reported by analyzers.

* Round 2 of analyzer fixes and general cleanup. (#1132)

* Analyzer fixes round 3. (#1135)

* Replace Array<T>.Empty with Array.Empty<T>() (#1137)

* Replace IsNullOrWhiteSpace extension (#1142)

* Use License Expression for NuGet Package

licenseUrl is deprecated, see https://github.com/NuGet/Announcements/issues/32

* Integration tests

* Remove todos

* Update CODEOWNERS

* Use correct SSH.NET

* ListDirectoryAsync return IAsyncEnumerable (#1126)

* ListDirectoryAsync return IAsyncEnumerable

* Fix documentation

* Update README.md

* Fix

* Add Sftp ListDirectoryAsync test

* Revert

* Integration tests for ListDirectoryAsync with IAsyncEnumerable

* Fix the assembly resolution build warning (#1165)

* Delete performance/longrunning tests (#1143)

Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com>

* Move Integration tests (#1173)

* Renci.SshNet.IntegrationTests

* Renci.SshNet.TestTools.OpenSSH

* Move integration tests to main repo

* Move old tests to new integration tests

* Move old integration tests to new integration tests

* Move more tests

* Move authentication tests

* Move SshClientTests

* Fix some tests

* Remove duplicated test

* Poc of ProcessDisruptor

* Rename

* Some fixes

* Remove performance tests

* Small improvements

* Add a benchmarks project (#1151)

* Add a benchmarks project

* Small improvements

---------

Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com>

* Use ExceptionDispatchInfo to retain call stack in Session.WaitOnHandle() (#936)

* Use ExceptionDispatchInfo to retain call stack in Session.WaitOnHandle()

* merge

* Update src/Renci.SshNet/Session.cs

Co-authored-by: Rob Hague <rob.hague00@gmail.com>

---------

Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com>
Co-authored-by: Rob Hague <rob.hague00@gmail.com>

* Support SHA256 fingerprints for host key validation (#1098)

* Add tests for HostKeyEventArgs

* Add SHA256 fingerprint support

* Add support for RSA SHA-2 public key algorithms (#1177)

* Abstract out the hash algorithm from RsaDigitalSignature

* Add integration tests

* Add DigitalSignature property to KeyHostAlgorithm

* Add IHostAlgorithmsProvider interface

* Verify the host signature

* Fix HostKeyEventArgsTest after merge

* Remove PubkeyAcceptedAlgorithms ssh-rsa

* Add test coverage for RSA keys in PrivateKeyFile

* Obsolete IPrivateKeySource

---------

Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com>

* Improvements after #1177 (#1180)

* Use ExceptionDispatchInfo in more places (#1182)

Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com>

* Try to "fix" the flaky test (#1185)

* Enable DSA tests (#1181)

Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com>

* FingerPrints (#1186)

* Use OS-agnostic socket error codes to allow tests run on different OSes (#1179)

SocketErrorCode is OS agnostic, ErrorCode is OS specific.

On Windows ErrorCode = (int) SocketErrorCode, but on Mac and Unix it is not.

For example ExitCode for HostNotFound (11001) on Windows is 11001, on Mac & Unix is -131073. So testing for ExitCode == 11001 fails on Mac & Unix.

Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com>

* Fix for channel session semaphore from thread blocking (#1071)

* Merging fix from @clivetong into our own SSH.NET fork
- The following article describes some of the issues with the double check lock that we have seen issues with: https://www.sudhanshutheone.com/posts/double-check-lock-csharp

* Merging fix from @clivetong into our own SSH.NET fork
- The following article describes some of the issues with the double check lock that we have seen issues with: https://www.sudhanshutheone.com/posts/double-check-lock-csharp

* Update Channel to fix AppVeyor failure (field should be readonly)

* Update ISftpClient for #120 (#1193)

* Implement set last write and access time (#1194)

* Add/migrate hmac+cipher integration tests (#1189)

* Add/migrate hmac+cipher integration tests

* fix integration tests

---------

Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com>

* Update tests for SetLastAccessTime(Utc) to also verify the time component and the Kind of the DateTime value returned by GetLastAccessTime(Utc). (#1198)

---------

Co-authored-by: Filippo Gualandi <filippo.gualandi@gmail.com>
Co-authored-by: 103filgualan <f.gualandi@crif.com>
Co-authored-by: Stefan Rinkes <darinkes@users.noreply.github.com>
Co-authored-by: wxtsxt <wojciech.swieboda@gmail.com>
Co-authored-by: Wojciech Swieboda <wswieboda@chathamfinancial.com>
Co-authored-by: Igor Milavec <igor.milavec@gmail.com>
Co-authored-by: drieseng <gert.driesen@telenet.be>
Co-authored-by: Pedro Fonseca <pbfonseca@gmail.com>
Co-authored-by: Pedro Fonseca <pfonseca@qti.qualcomm.com>
Co-authored-by: Maximiliano Jabase <maxijabase@gmail.com>
Co-authored-by: Owen Krueger <37021716+Owen-Krueger@users.noreply.github.com>
Co-authored-by: Masuri <psh0258@gmail.com>
Co-authored-by: LemonPi314 <49930425+LemonPi314@users.noreply.github.com>
Co-authored-by: Gert Driesen <gertdriesen@msn.com>
Co-authored-by: Rob Hague <rob.hague00@gmail.com>
Co-authored-by: Rob Hague <rh@johnstreetcapital.com>
Co-authored-by: Marius Thesing <marius.thesing@gmail.com>
Co-authored-by: Dāvis Mošenkovs <davikovs@gmail.com>
Co-authored-by: Dmitry Tsarevich <dimhotepus@users.noreply.github.com>
Co-authored-by: Patrick Yates <114094360+patrick-yates-redgate@users.noreply.github.com>

* Remove code examples

---------

Co-authored-by: Filippo Gualandi <filippo.gualandi@gmail.com>
Co-authored-by: 103filgualan <f.gualandi@crif.com>
Co-authored-by: Stefan Rinkes <darinkes@users.noreply.github.com>
Co-authored-by: wxtsxt <wojciech.swieboda@gmail.com>
Co-authored-by: Wojciech Swieboda <wswieboda@chathamfinancial.com>
Co-authored-by: Igor Milavec <igor.milavec@gmail.com>
Co-authored-by: drieseng <gert.driesen@telenet.be>
Co-authored-by: Pedro Fonseca <pbfonseca@gmail.com>
Co-authored-by: Pedro Fonseca <pfonseca@qti.qualcomm.com>
Co-authored-by: Maximiliano Jabase <maxijabase@gmail.com>
Co-authored-by: Owen Krueger <37021716+Owen-Krueger@users.noreply.github.com>
Co-authored-by: Masuri <psh0258@gmail.com>
Co-authored-by: LemonPi314 <49930425+LemonPi314@users.noreply.github.com>
Co-authored-by: Gert Driesen <gertdriesen@msn.com>
Co-authored-by: Rob Hague <rob.hague00@gmail.com>
Co-authored-by: Rob Hague <rh@johnstreetcapital.com>
Co-authored-by: Marius Thesing <marius.thesing@gmail.com>
Co-authored-by: Dāvis Mošenkovs <davikovs@gmail.com>
Co-authored-by: Dmitry Tsarevich <dimhotepus@users.noreply.github.com>
Co-authored-by: Patrick Yates <114094360+patrick-yates-redgate@users.noreply.github.com>
2023.0.1
2023-12-29 07:45:20 +01:00
Rob Hague 4c2dcd5613 Upgrade packages (#1279) 2023-12-29 05:06:50 +01:00
Rob Hague 2b53e462dd Authenticate with ssh-rsa by default (#1283) 2023-12-28 20:55:07 +01:00
Jim Killingsworth e7a64dda97 Fix hung dispose caused by infinite socket timeout (#1280)
Co-authored-by: Rob Hague <rob.hague00@gmail.com>
2023-12-28 11:52:00 +01:00
Rob Hague b0d01df91f Try to stabilise a few tests (#1278)
* Try to stabilise a few tests

* Fix random 0 buffer sizes

---------

Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com>
2023-12-22 08:37:30 +01:00
Rob Hague 24838e6173 Make keys immutable (#1264)
This makes it easier to reason about Key instances in e.g.
DigitalSignature implementations, because we know that the
Key is initialised with its data and will not change.

Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com>
2023-12-21 23:12:15 +01:00
Rob Hague e998d875e0 Add a few spans on net6.0 or greater (#1138) 2023-12-21 21:32:20 +01:00
Rob Hague 34b5123f0a Send the client key exchange init in Connect (#1274)
* Send the client key exchange init in Connect

* Add a test

---------

Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com>
2023-12-21 06:54:32 +01:00
Scott Xu 326ce14c4c Maintain current build solution (#1268)
* Add .NET 8.0 to current build project.
Add dependency **Microsoft.Bcl.AsyncInterfaces** for net462 and netstandard2.0 for current nuget spec

* Remove last new line

* Tabify
2023-12-15 16:54:57 +01:00
Jacob Slusser f4371ffccc Reduces heap allocations for the some byte[] uses (#1272) 2023-12-11 10:07:32 +01:00
Jacob Slusser f172ac587c Removes MessageAttribute in favor of properties on Message class (#1270)
* Exludes the test projects from code coverage reports

* Removes MessageAttribute in favor of properties on Message class

* Benchmark for removal of MessageAttribute
2023-12-10 17:46:35 +01:00
Wojciech Nagórski 6220beb83d Native async (#1267) 2023-12-09 12:28:06 +01:00
Rob Hague 04178d8432 Always use factories for HmacAlgorithms (#1262)
* Always use factories for HmacAlgorithms

* Re-order HmacAlgorithms

---------

Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com>
2023-12-09 11:30:57 +01:00
Rob Hague f45af38628 Replace SemaphoreLight with SemaphoreSlim (#1265)
This paves the way for asynchronous synchronisation via WaitAsync
(and eliminates a timing test which sometimes fails in CI)

Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com>
2023-12-09 08:52:31 +01:00
Jacob Slusser 4c4883eed0 Standardizes additional file types in .editorconfig (#1266)
* Updates .gitignore to exclude test results

* Adds .editorconfig for xml, csproj, and props files

Formats xml, csproj, and props files

* Hides stylecop.json from Solution Explorer projects
2023-12-09 07:39:33 +01:00
Rob Hague 6d9d03205b Rebased AsyncResult fix (#1184)
* 🐛 AsyncResult contains invalid value

- AsyncResult should contain invalid value immediately after async operation is marked as completed
- there was race condition problems with callback method which is invoked on different thread so updating of value is done without any synchronization. So in some cases async operation is marked as completed but async result value is not yet updated and contains invalid value

* Revert test

---------

Co-authored-by: Miroslav Pokorný <m.pokorny@quadient.com>
2023-12-04 09:48:56 +01:00
Rob Hague 9b0262c5fb Disable some impactful analyzers (#1246)
* Disable some impactful analyzers

* fb

---------

Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com>
2023-12-02 16:41:32 +01:00
Rob Hague a027c76d7a Fail with a friendlier error message when response has not been set (#1245)
Co-authored-by: Wojciech Nagórski <wojtpl2@gmail.com>
2023-12-02 14:16:22 +01:00
Scott Xu 4c7bd35a71 Add support for .NET 8.0 (#1255)
* Add support for .NET 8.0

* Fix CA1512: Use 'ArgumentOutOfRangeException.ThrowIfNegative' instead of explicitly throwing a new exception instance (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1512)

* Use `ThrowIfGreaterThan` instead of `ThrowIfNegative`+calculation, to supply the correct parameter name.

* .NET 8 is faster :-)

* Use the explicit version, in case newer version SDK breaks our tests
2023-12-01 22:56:48 +01:00
Wojciech Nagórski d3641a0676 Test integration tests (#1250)
* Test integration tests

* Update appveyor.yml

* Update appveyor.yml

* Update Dockerfile

* Update appveyor.yml

* test?

* Test

* Enable docker

* Update appveyor.yml

* Update appveyor.yml

* Fix & Show additional information

* Try to fix connection problems

* Fix build

* remove artifacts

* Enable logging

* Log Information only

* Update appveyor.yml

Co-authored-by: Rob Hague <rob.hague00@gmail.com>

* Update appveyor.yml

* Update appveyor.yml

Co-authored-by: Rob Hague <rob.hague00@gmail.com>

* Update appveyor.yml

Co-authored-by: Rob Hague <rob.hague00@gmail.com>

* Update appveyor.yml

* Update appveyor.yml

* Update appveyor.yml

* Update appveyor.yml

* Update appveyor.yml

* Update appveyor.yml

* Update appveyor.yml

* Update appveyor.yml

* Update appveyor.yml

* sleep after restarting

* Update RemoteSshd.cs

* Fix tests

* Dispose ports

* Small improvements

* Fix build

* Small fixes

* Revert not related changes

* Test linux and windows

* fix

* test_script

* Use real commands

* Fixes

* fix?

* Add Appveyor TestLogger

* Fix linux tests

* Fix tests

* Try to fix tests

* Revert

* Give time before

* fix

* revert

* Give some time to process all messages after connect

* ForwardedPortDynamicTest_Stop_PortStarted_ChannelNotBound

* fix netsh

* trace

* Update appveyor.yml

* Update appveyor.yml

* etl2pcapng

* Update appveyor.yml

???

* Update appveyor.yml

* Update appveyor.yml

* Update appveyor.yml

* Update appveyor.yml

* come on !!

* Update appveyor.yml

* Fixes tests for linux

* Reverts

* Fix build

* Update TestMethodForPlatformAttribute.cs

* Update TestMethodForPlatformAttribute.cs

* Update appveyor.yml

* Issue #1253

* Install .NET SDK

* next try

* fix?

* try

* Finishing

* Fixes

* apt-get install dotnet-sdk-7.0

* Finish?

* Add environment APPVEYOR_BAKE_IMAGE

* Update test/Renci.SshNet.Tests/Classes/Connection/DirectConnectorTest_Connect_TimeoutConnectingToServer.cs

Co-authored-by: Rob Hague <rob.hague00@gmail.com>

* Fix review

* Fix

* Update appveyor.yml

* Update appveyor.yml

* Delete .runsettings

---------

Co-authored-by: Rob Hague <rob.hague00@gmail.com>
Co-authored-by: Robert Hague <rh@johnstreetcapital.com>
Co-authored-by: Scott Xu <scott-xu@msn.com>
2023-11-30 19:19:00 +01:00
Gert Driesen 5921b6eca3 Disable a few duplicate analyzer rules. (#1254) 2023-11-30 07:40:13 +01:00