EldoS | Feel safer!

Software components for data protection, secure storage and transfer

No SFTP in Silverlight?

Posted: 08/26/2011 11:32:32
by Freddi Kahlen (Basic support level)
Joined: 08/26/2011
Posts: 2

Hello everybody,

we at our company want to buy the blackbox sft stuff, but we ran into some trouble.
We are trying to get sftp working in a Silverlight client. But after some tinkering and further research we dont have any clue how to get it working.

We just get error 10060 in silverlight, in the console demo everything is working great!

Please help, and post some simple demo code.

Thanks in advance!

Current testing code wich is not working in silverlight:


Imports SBSftpCommon

Imports SBSimpleSftp

Partial Public Class MainPage
    Inherits UserControl

    Dim Client As TElSimpleSFTPClient

    ' command line parameters
    Const OP_LIST As Integer = 1
    Const OP_DOWNLOAD As Integer = 2
    Const OP_UPLOAD As Integer = 3

    Dim parOperation As Integer = 0
    Dim parRemoteName As String = "/"
    Dim parLocalName As String
    Dim parUsername As String = "USER"
    Dim parPassword As String = "PASS"
    Dim parAddress As String = "sftp.our-company.com"
    Dim parPort As Integer = 22

    Public Sub New()
    End Sub

    Private Sub m_Client_OnKeyValidate(ByVal Sender As Object, ByVal ServerKey As SBSSHKeyStorage.TElSSHKey, ByRef Validate As Boolean)
        System.Console.WriteLine("Server key received")
        Validate = True ' NEVER do this. You MUST check the key somehow
    End Sub

    Private Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles Button1.Click

        SBUtils.Unit.SetLicenseKey("DEMO KEY STRING")

        Client = New TElSimpleSFTPClient
        Client.Address = parAddress
        Client.Port = parPort
        Client.Username = parUsername
        Client.Password = parPassword

        AddHandler Client.OnKeyValidate, AddressOf m_Client_OnKeyValidate


        Dim _name As String = Client.ServerSoftwareName



    End Sub
End Class
Posted: 08/26/2011 12:12:50
by Eugene Mayevski (Team)

Please see this FAQ article which addresses exactly your question. If you have further questions after reading the FAQ, feel free to ask.

Sincerely yours
Eugene Mayevski
Posted: 08/30/2011 06:21:02
by Freddi Kahlen (Basic support level)
Joined: 08/26/2011
Posts: 2


that article helped alot. Thank you.
We finally came to the conclusion that silverlight still isnt the right tool for us. We have done it in a different Framework. Maybe Silverlight 5 will be worth trying it again.

Have a nice day.
Posted: 02/14/2012 11:29:01
by mbudiman (Basic support level)
Joined: 02/14/2012
Posts: 10


I'm somewhat in the same boat; trying to create an in-browser Silverlight app that can do SFTP uploads / downloads. I am using the trial at the moment.

I've read and understood the socket limitations per MSDN documentation, and I've applied a clientaccesspolicy.xml file on the server. I've also mapped proper ports on the FTP server (I'm using Cerberus) so it will accept connection on 4502 and 4503 (SFTP and FTP respectively).

Running OOB seems to work fine; but I would like to get a solution where it's running in-browser. I can use the .NET's Socket class and I can connect (Success status) - but I always get a 10013 error when then using the TElSimpleFTPSClient class.

I saw that there's a way to not use the internal socket, but I can't find any example on this. Any suggestions on how to proceed?

Muljadi Budiman.
Posted: 02/14/2012 12:49:03
by Ken Ivanov (Team)

Thank you for contacting us.

The symptoms you are observing are quite strange, as SBB components use the same .NET Socket objects internally. I guess some configuration issue might be taking place here. First of all, please double check that you are specifying server address and port correctly in the component's settings (I acknowledge that it may sound dumb - sorry if it does, - but according to our experience, incorrectly specified credentials is in fact one of the most popular reasons for connectivity issues). If the configuration is correct, could you please send us a sample project that can be used to reproduce the issue locally? I believe that the one you are doing your testing with will help much.

Indeed, there does exist a way of substituting the internal socket, however, a better solution would be to track down what's wrong with the internal socket-based configuration and try to fix it. The main argument for postponing the substitution of the socket is that this task is a bit time-consuming and will require certain amount of coding.
Posted: 02/14/2012 16:38:33
by mbudiman (Basic support level)
Joined: 02/14/2012
Posts: 10


I have an SL 4 project that demonstrates the issue. The main page has 2 buttons:
1. Connect using socket (this one will be successful, assuming the clientaccesspolicy.xml is in place)
2. Connect using SFTP (this one always fail)

Since I can't attach a file, I'll paste the code below. Since the code is public, I've taken out the IP address - if you guys need the server to test further, email me and I'll send the IP address. Please note that I didn't put in a username/password since with or without them I always get a 10013 exception.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Net.Sockets;
using SBSimpleSftp;
using SBSSHCommon;

namespace TestSFTP
    public partial class MainPage : UserControl
        public MainPage()

        const string FTPSite = "IPAddressHere";
        const int SftpPort = 4502;

        private void button1_Click(object sender, RoutedEventArgs e)
            Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            SocketAsyncEventArgs args = new SocketAsyncEventArgs();
            args.SocketClientAccessPolicyProtocol = SocketClientAccessPolicyProtocol.Http;
            args.RemoteEndPoint = new IPEndPoint(IPAddress.Parse(FTPSite), SftpPort);
            args.Completed += new EventHandler<SocketAsyncEventArgs>(args_Completed);
            args.UserToken = sock;

        void args_Completed(object sender, SocketAsyncEventArgs e)
            if (Dispatcher.CheckAccess() == false)
                Dispatcher.BeginInvoke(() => args_Completed(sender, e));

            if (e.SocketError == SocketError.Success)
                MessageBox.Show("Some error occurred");

            Socket sock = (Socket)e.UserToken;

        private void button2_Click(object sender, RoutedEventArgs e)

                TElSimpleSFTPClient client = new TElSimpleSFTPClient();
                client.UseInternalSocket = true;
                client.Address = FTPSite;
                client.Port = SftpPort;
                client.OnKeyValidate += new TSSHKeyValidateEvent(client_OnKeyValidate);

            catch (Exception ex)


        void client_OnKeyValidate(object Sender, SBSSHKeyStorage.TElSSHKey ServerKey, ref bool Validate)
            Validate = true;

I'd appreciate a solution to this, or other recommendations to proceed further.

Muljadi Budiman.
Posted: 02/14/2012 17:01:13
by Ken Ivanov (Team)

Thank you for the code, it will help us investigate the issue much faster. We have set up a local testing server, so we will need the IP of your server only if we are unable to reproduce the problem locally.

We will get back to you as soon as we get some results with this.
Posted: 02/14/2012 18:57:51
by Ken Ivanov (Team)

I guess we have found the reason for the issue. The internal socket component incorrectly sets up client access policy configuration while configuring the native socket component. We have managed to fix the problem, and ended up with SL-originating connections being always established correctly for us. The fix is going to be incorporated into the future SecureBlackbox installation update.

Thank you very much indeed for reporting the issue to us.

There is one thing we'd also like to ask you about. Although the fix does work in our environment and we are sure it is correct, it is always good to add another layer of confidence. Would you mind doing a little check for us so that we were sure that the problem is resolved on your side too?
Posted: 02/14/2012 22:16:19
by mbudiman (Basic support level)
Joined: 02/14/2012
Posts: 10


It's great that you've found a fix for it. I would be glad to confirm the fix and check to make sure it works on my test environment as well. How do I get the updated assembly / assemblies?

Muljadi Budiman.
Posted: 02/15/2012 06:27:58
by Ken Ivanov (Team)

Great, thank you!

I have created a Helpdesk ticket for you and attached the updated assembly there.



Topic viewed 3488 times

Number of guests: 1, registered members: 0, in total hidden: 0


Back to top

As of July 15, 2016 EldoS business operates as a division of /n software, inc. For more information, please read the announcement.

Got it!