Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UWP support? #4

Closed
xied75 opened this issue Feb 12, 2016 · 29 comments
Closed

UWP support? #4

xied75 opened this issue Feb 12, 2016 · 29 comments
Assignees

Comments

@xied75
Copy link

xied75 commented Feb 12, 2016

First of all, big welcome to migrate to GitHub!

The question is, how much effort would take to make a version for UWP? Is it in the team's pipe line?

Best wishes.

@drieseng
Copy link
Member

I'm active working on it.
As a first step, I'm refactoring our cryptography classes into a separate assembly (and nuget).
I'm almost done with this (locally).
Once this is done, it should be relatively easy to get SSH.NET to compile as UWP/UAP library.

To considered it done, I'd like to perform tests on Windows Mobile 10.
Problem is that MS decided not to support the upgrade to Windows Mobile 10 for my device (Lumia 925) :(:(

@drieseng drieseng mentioned this issue Mar 20, 2016
@drieseng drieseng self-assigned this Mar 20, 2016
@xied75
Copy link
Author

xied75 commented Mar 21, 2016

@drieseng As I understand there are two ways to make library for UWP:

1, you create a UWP library project in VS 2015;
2, you create a PCL project including support for UWP in VS 2015.

Both way, you will see .NET api you can call is reduced a lot. But as long as you do as above, there is no need to test it on real hardware to be confident it is done.

I got a 735 which will be upgraded to 10, so I can help testing it. :)

@xied75
Copy link
Author

xied75 commented Apr 4, 2016

@drieseng just to say I got Win 10 on my 735 over the weekend, so ready to do testing.

@drieseng
Copy link
Member

drieseng commented Apr 5, 2016

I'm using the new CoreFX libraries to bridge some of the gap between the UWP SDK and our specific needs. I have SSH.NET building just fine for UWP/UAP10.0, but CoreFX issue #7387 prevents me from testing it.

@codelabexpert
Copy link

Hi,
when UAP Support will be ready? I have problems to compile development branch... more than 35107 errors?

@drieseng
Copy link
Member

Sorry about that. I've started to move away from the (.NET Core) CoreFx libraries - as RC2 is still not available, and I still need to release a nuget for SshNet.Security.Cryptography. This is necessary because I moved some of our crypto stuff to a separate repo.

Last week, I spent some time working on release automation. I'm sure to recover most of that time later, and at the same releasing new versions should become less of a burden.

I'll make sure the development branch gets in a stable state this weekend.

@codelabexpert
Copy link

@drieseng Thank you! I would be happy if I can compile the source.

@drieseng
Copy link
Member

I made a bad decision upgrading my dev machine to W10 build 14328.
It broke virtualbox, and blue screens whenever I attempt to install the WP8 SDK.
This means I cannot access my (Linux) VM to test SSH.NET, and I cannot use the VS 2012 solution.

So I did not make as much progress as I hoped.
The VS 2015 solution in the development branch should compile, but I can't guarantee more than that.

@codelabexpert
Copy link

Hm, what I am doing wrong? I try to compile the Project in VS2015 Update 2 and get nearly 35000 Errors (Int32 not found, System not found and so on)...Do you have any ideas?

@drieseng
Copy link
Member

Can you check what version of the Microsoft ASP.NET and Web Tools you have installed ? I have version 14.1.20203.0.

Also make sure you have at least version 3.4.0.798 of the NuGet Package Manager extension.

Do you get any package restore errors ?

@codelabexpert
Copy link

codelabexpert commented Apr 24, 2016

ssh_errors

VS 2015 is up to date. I've attached a screenshot where you find all package restore errors.

@drieseng
Copy link
Member

I'll verify this later today, but I think I forgot to push my local changes :(

@codelabexpert
Copy link

Ok! I am waiting... ;-)

@drieseng
Copy link
Member

I just pushed my changes, let me know if you have any issues building.
Note that I'm 100% sure there are still issues actually using it.

@codelabexpert
Copy link

codelabexpert commented Apr 25, 2016

Thank you a lot for your work! But there are still Errors (only 64 remaining).
E.g.:

  • Nuget package SshNet.Security.Cryptography cannot be found. So I compiled your repository and linked it but there are still old references.
  • Class "RandomNumberGenerator" cannot be found
  • Cannot found "System.Security.Cryptography.HMACSHA512"

UPDATE:
I reduced the feature list to "TUNING;FEATURE_SOCKET_EAP;FEATURE_STREAM_TAP;FEATURE_THREAD_TAP;FEATURE_MEMORYSTREAM_TRYGETBUFFER;FEATURE_REFLECTION_TYPEINFO"

Now I was able to build a library for UWP.

@drieseng
Copy link
Member

I can confirm that the framework features toggles were not yet correct for UAP10/UWP.
I've just commit a fix for this.
Do you still have a problem with the SshNet.Security.Cryptography nuget package?
I committed to the packages folder yesterday. This should be considered temporary until I've released that package on nuget.org.

@codelabexpert
Copy link

codelabexpert commented Apr 25, 2016

I resolved all problems and was able to create a library. A little UWP app was not able to connect to Ubuntu 15.10. In debug mode I saw that the server version was recognized but the connection was not established ("Client not connected"). Timeout was set to 30 seconds.

But PuTTY is able to connect.

UPDATE:
It seems that "SocketAbstraction.CanWrite" always return FALSE because FEATURE_SOCKET_POLL is deactivated. This is the reason why SshConnectionException is thrown with "Client not connected".

    internal static bool CanWrite(this Socket socket)
    {
        return SocketAbstraction.CanWrite(socket);
    }

@drieseng
Copy link
Member

Yeah, just found out myself.
Same lame bug exists in CanRead.
I fixed both.
This should get you at least a little bit further.

Note that I still haven't been able to test with UWP.
Hoping a new version of VirtualBox is available soon.

@codelabexpert
Copy link

Ok, thank you.
public BigInteger(byte[] value) needed a fix. Otherwise it runs in a IndexOutOfRangeException. Trying to connect to a server ends in "An established connection was aborted by the server.".

Do you need VirtualBox? What about Hyper-V or Azure?

@drieseng
Copy link
Member

I don't necessarily need virtualbox, but that's what I chose to run my VM in.
I could create a new one in Hyper-V or Azure, but I haven't yet had time to look into these.
I have an Azure acount but never used it.

As for the issue you ran into: I doubt it's a problem in BigInteger. I'm more inclined to think we did a partial read from a socket. Can you reproduce it using a public SSH server ?
Can you also provide the full stack trace ?

@drieseng
Copy link
Member

Upgrading to a new W10 build and a daily build of VirtualBox fixed the VirtualBox issue.
That should allow me to pick up speed.

I've fixed the "BigInteger" problem - which was actually an issue in HashAlgorithmFactory.GenerateRandom(byte[]).
I'll commit the fixed once I've added unit tests for this method.
This should be tomorrow evening.

If you can't wait that long, here's the fix:

var buffer = Windows.Security.Cryptography.CryptographicBuffer.GenerateRandom((uint) data.Length);
System.Runtime.InteropServices.WindowsRuntime.WindowsRuntimeBufferExtensions.CopyTo(buffer, data);

@codelabexpert
Copy link

You made my day! The fix did it. But what is the significant difference between
System.Runtime.InteropServices.WindowsRuntime.WindowsRuntimeBufferExtensions.CopyToand Windows.Security.Cryptography.CryptographicBuffer.CopyToByteArray?

@drieseng
Copy link
Member

We were not passing the data byte array by reference, and as such CopyToByteArray was not initializing the byte array that was passed to the GenerateRandom(byte[]) method.

You'll find a much better explanation here.

@drieseng
Copy link
Member

I've now committed the fix, and corresponding unit tests.
Haven't had time yet to do more fixing.
Should have more time in the weekend.
Let me know if ("when" is more approriate at this stage) you run into any issues.

@codelabexpert
Copy link

I tested 6 days long and there where no issues. But there are a lot of features disabled. Some features need CoreFX RC 2+.

@drieseng
Copy link
Member

drieseng commented May 5, 2016

There are no SSH.NET features disabled at all for UWP.
The FEATURE_* symbols that we use in our code are used to define the capabilities of each target framework. They do not define what features are available in SSH.NET.

Example:
For UWP applications, System.Threading.Thread.Sleep(int) is not available. Hence the FEATURE_THREAD_SLEEP symbol is not defined in our Renci.SshNet.UAP10 project.
Instead we use System.Threading.Tasks.Task.Delay(millisecondsTimeout) for this purpose, as defined by the FEATURE_THREAD_TAP symbol.

Does that make things more clear for you ?

@drieseng
Copy link
Member

I've just released SSH.NET 2016.0.0-beta1, which introduces support for UAP 10 / UWP.

@Aerolyte
Copy link

Hello i am having issue with SSH.net. I will really appreciate any advice:
I get the following error: An attempt was made to access a socket in a way forbidden by its access permissions. I have looked online and there is no one actually dealing with this.The exact same code works in a standard Desktop App (WPF). What could be wrong, please?: (key = key.Replace("\r", "\n"); PrivateKeyFile(stringToStream(key)); client = new SshClient(ip, port, username, pkf); if (!client.IsConnected) { try { client.Connect(); connected = true; } catch (Exception ex) { exception = ex.Message.ToString(); connected = false; } })

@drieseng
Copy link
Member

Pretty sure this is a security issue. What capabilities is your application requesting?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants