-
-
Notifications
You must be signed in to change notification settings - Fork 940
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
String Reference not set to an instance of a String: Parameter name: s #382
Comments
To be honest: I have no idea what may be causing this exception. Can you share the full stack trace? |
Hi, Here is the stack trace 'TestSFTP.vshost.exe' (CLR v4.0.30319: TestSFTP.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. Error Message String reference not set to an instance of a String. |
I found this same error. I pulled down the repo, checked out the tag: "2016.1.0" and built on debug.
This was less than helpfull since C:\src\SSH.NET\src\Renci.SshNet\KeyboardInteractiveAuthenticationMethod.cs:line 78 is the retun statement of that method. I thought that the This gave a more informative stacktrace:
|
Looks like the problem is in writing the InformationResponseMessage to the SshDataStream. I thought I was setting up an AuthenticationPrompt EventHandler to provide a response. I'll have to check that I am doing that correctly. |
Looks like my problem is powershell: it doesn't allow for a synchronous event handling. |
Outside of powershell's (lack of) event handling support, the most likely cause of this error is using a Since if there is no AuthenticationPrompt or it comes back with an 'AuthenticationPrompt.Response' thats null, it will bubble up to I think the fix is to either test 'AuthenticationPrompt.Response' for null and fail early with a friendly message, or initialize 'AuthenticationPrompt.Response' to an empty string before passing it to the handler (i.e. assume no password, I guess), or both. |
I simply managed this in PowerShell Posh-SSH module by building the auth part in C# as a binary module to handle the event
…Sent from my iPhone
On Aug 10, 2018, at 3:52 PM, Kyle Shanafelt ***@***.***> wrote:
Outside of powershell's (lack of) event handling support, the most likely cause of this error is using a KeyboardInteractiveAuthenticationMethod (or a KeyboardInteractiveConnectionInfo) without registering an AuthenticationPrompt event handler.
Since if there is no AuthenticationPrompt or it comes back with an 'AuthenticationPrompt.Response' thats null, it will bubble up to SshDataStream.Write and fail to GetBytes from null.
I think the fix is to either test 'AuthenticationPrompt.Response' for null and fail early with a friendly message, or initialize 'AuthenticationPrompt.Response' to an empty string before passing it to the handler (i.e. assume no password, I guess), or both.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
The issue I had stemmed from trying to confirm the password prompt. For some reason the system was able to recognize that there was a prompt but had a null string in the prompt request. If you catch for null and send the password anyways, which I don't recommend, it may work. |
I've opened another tread, since I thought this is a version-related issue , same goes for 2020.2 at Renci.SshNet.KeyboardInteractiveAuthenticationMethod.Authenticate(Session session) at Renci.SshNet.ClientAuthentication.TryAuthenticate(ISession session, AuthenticationState authenticationState, String[] allowedAuthenticationMethods, SshAuthenticationException& authenticationException) at Renci.SshNet.ClientAuthentication.Authenticate(IConnectionInfoInternal connectionInfo, ISession session) at Renci.SshNet.ConnectionInfo.Authenticate(ISession session, IServiceFactory serviceFactory) at Renci.SshNet.Session.Connect() at Renci.SshNet.BaseClient.CreateAndConnectSession() at Renci.SshNet.BaseClient.Connect()` |
i think i've found the issue which might point to a BUG keyboard-interactive
` when there is an issue / authentication method not defined when i've change the order / removed the user interactive everything worked fine |
@amitbarkai Thanks. In your As for the order of the authentication methods, the library tries them in the order you have specified. It's plausible that when you specify If you think there is still something wrong (there could be), you would be welcome to try and demonstrate using an integration test. You can find examples in the |
@Rob-Hague yes
` this issue happens for both 2016 and 2020 since this issue happens for one of our customers , we where not able to reproduce it yet. it sound like an edge case , but still a bug :) |
another important note . also what made this issue waired :) , is that when i've tried to connect via PuTTy it worked fine for both local and domain users |
Thanks, I have annotated your code with what could be causing the error. foreach (var prompt in e.Prompts)
{
// Write To Log
if (passwordRegex.IsMatch(prompt.Request))
{
prompt.Response = passwordConnection.Password.GetStringFromSecureString();
+ // If the value of passwordConnection.Password.GetStringFromSecureString() is null, you will get the error.
}
else
{
// Write To Log
+ // If you do not set prompt.Response here, you will get the error.
}
}
|
i see where you going :)
but i would expect the log line to appear in my logs.
so i am not sure , that would be the case here.
public SshClient(IMachine machine, string username, SecureString
password, int port, TimeSpan connectionTimeout)
{
try
{
ConnectionInfo = new PasswordConnectionInfo(machine.Address,
username, password, port);
var keyboardAuth = new
KeyboardInteractiveAuthenticationMethod(username);
keyboardAuth.AuthenticationPrompt +=
keyboardAuthentication_AuthenticationPrompt;
var passwordAuth = new
Renci.SshNet.PasswordAuthenticationMethod(username,
password.GetStringFromSecureString());
var connectionInfo = new
Renci.SshNet.ConnectionInfo(machine.Address, port, username, keyboardAuth,
passwordAuth);
connectionInfo.Timeout = connectionTimeout;
_client = new Renci.SshNet.SshClient(connectionInfo);
setShellColumns(machine);
}
catch (Exception ex)
{
throw new Exception(string.Format(LogMessages.209E,
ex.Message), ex);
}
}
and if the issue was really what you've pointed on , i would expect it to
be in the stack trace .
11/9/2023 8:40:27 AM [5960][7] - ConnectClient - Kaiser - Connect Exception
data: System.ArgumentNullException: String reference not set to an instance
of a String.
Parameter name: s
at
Renci.SshNet.KeyboardInteractiveAuthenticationMethod.Authenticate(Session
session)
at Renci.SshNet.ClientAuthentication.TryAuthenticate(ISession session,
AuthenticationState authenticationState, String[]
allowedAuthenticationMethods, SshAuthenticationException&
authenticationException)
at
Renci.SshNet.ClientAuthentication.Authenticate(IConnectionInfoInternal
connectionInfo, ISession session)
at Renci.SshNet.ConnectionInfo.Authenticate(ISession session,
IServiceFactory serviceFactory)
at Renci.SshNet.Session.Connect()
at Renci.SshNet.BaseClient.CreateAndConnectSession()
at Renci.SshNet.BaseClient.Connect()
at Cyberark.DNA.Common.Communication.SSH.SshClient.Connect()
and this was my stack trace
for this function
…On Sun, Nov 19, 2023 at 11:47 AM Rob Hague ***@***.***> wrote:
Thanks, I have annotated your code with what could be causing the error.
prompt.Response must always be set to not-null, otherwise the error will
appear (a weird design).
foreach (var prompt in e.Prompts)
{
// Write To Log
if (passwordRegex.IsMatch(prompt.Request))
{
prompt.Response = passwordConnection.Password.GetStringFromSecureString();+ // If the value of passwordConnection.Password.GetStringFromSecureString() is null, you will get the error.
}
else
{
// Write To Log+ // If you do not set prompt.Response here, you will get the error.
}
}
—
Reply to this email directly, view it on GitHub
<#382 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACKFETV5SYFJJSPTERRM36LYFHISTAVCNFSM4EPFGCV2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOBRG44DAMZUG43Q>
.
You are receiving this because you were mentioned.Message ID: <sshnet/SSH.
***@***.***>
|
The exception is actually originally thrown on a different thread and then re-thrown in |
i understand, so you command to move to 2023?
[image: image.png]
i think the issue I am experiencing is different , since I would expect to
see either of the marked logs.
…On Sun, Nov 19, 2023 at 12:44 PM Rob Hague ***@***.***> wrote:
The exception is actually originally thrown on a different thread and then
re-thrown in KeyboardInteractiveAuthenticationMethod.Authenticate, so
that's why the stack trace looks strange. I expect that if you use version
2023.0.0, the stack trace would look slightly different (because of #1182
<#1182>).
—
Reply to this email directly, view it on GitHub
<#382 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACKFETXKJVHZMZO2U6RARO3YFHPI7AVCNFSM4EPFGCV2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOBRG44DCNRTG43A>
.
You are receiving this because you were mentioned.Message ID: <sshnet/SSH.
***@***.***>
|
You will still get the error in 2023.0.0, but the stack trace might be different. I can't see the image in your comment. Maybe we can continue the discussion in your issue #1237 instead of this one. |
The 2023.0.1 version has been released to Nuget: https://www.nuget.org/packages/SSH.NET/2023.0.1 |
I am working on a program that must upload files to various clients it has worked well except for one client.
I have stripped out the relevant code that I am using to make it easier to debug and I have included it below.
I get the error as per the subject line of this submission when I execute it, can anyone provide some clarity for me as to what am doing wrong, I am an old programmer and have learnt to accept that it is invariably my fault:
The error occurs when it tries to execute the connect
The program is written in Visual Basic using Visual Studio 3013
Imports Renci.SshNet
Public Class Form
End Class
Regards
Juliana
The text was updated successfully, but these errors were encountered: