login about faq

I have seen the other question on this forum that indicates that a key should be regenerated. But I used the Chilkat libs to generate a new key (code below) and got the same error. I'm thinking I must be doing something wrong.

        var key = new SshKey();

        success = key.GenerateRsaKey(2048, 65537);
        if (!success)
            throw new Exception(string.Format("Chilkat failed! {0}", key.LastErrorText));

        var keystr = key.ToRfc4716PublicKey();
        if (keystr == null)
            throw new Exception(string.Format("Chilkat failed! {0}", key.LastErrorText));

        success = key.SaveText(keystr, "ShinyNewKey.pub");
        if (!success)
            throw new Exception(string.Format("Chilkat failed! {0}", key.LastErrorText));
        Console.ReadLine();
        return;

Then when I turn around and read in the key using the Chilkat funcs it fails with the p is not prime error.

Is there something obvious that I am doing wrong? Ultimately I am just trying to get the code below to work. I'm evaluating Chilkat for sftp since none of the other offerings seem to support the SSH2 public key with a user/pwd as well.

Any help is appreciated.

var pkey = key.LoadText(keyfile);
        if (pkey == null)
            throw new Exception(string.Format("Chilkat failed! {0}", key.LastErrorText));

        success = key.FromRfc4716PublicKey(pkey);            
        if (!success)
            throw new Exception(string.Format("Chilkat failed! {0}", key.LastErrorText));

        success = csftp.AuthenticatePwPk(user, pwd, key);
        if (!success)
            throw new Exception(string.Format("Chilkat failed! {0}", csftp.LastErrorText));

asked May 07 '13 at 16:09

Erik's gravatar image

Erik
6112


I found the problem: The software was trying to verify a public key as if it were a private key. The public key does not have the various parts that are present for a private key, and therefore there is no "P" to check for prime. The fix was easy -- to omit the verification for those parts.

Here's the new build: http://www.chilkatsoft.com/preRelease/ChilkatDotNet4-9.4.1-win32.zip

PS> Pre-release notes will also be logged to the Chilkat blog here: http://www.cknotes.com/?cat=371

link

answered May 08 '13 at 18:17

chilkat's gravatar image

chilkat ♦♦
11.8k316358420

Make sure you're using the very latest version of Chilkat.

link

answered May 07 '13 at 16:23

chilkat's gravatar image

chilkat ♦♦
11.8k316358420

I downloaded and ref'd the .net 4 version of the assembly today (5/7/2013) from the site. Is there a different version / place I should be accessing it from? My code is running .net 4, so I figured that was the right version for me to download.

link

answered May 07 '13 at 16:29

Erik's gravatar image

Erik
6112

Just noticed that you always like to see the LastErrorText (should have included that before). Here it is:

System.Exception was unhandled

HResult=-2146233088 Message=Chilkat failed! ChilkatLog: FromRfc4716PublicKey: DllDate: Dec 12 2012 UnlockPrefix: here we go.... Username: LT0050-1:edahl Architecture: Little Endian; 32-bit Language: .NET 4.0 VerboseLogging: 0 Parsed public key blob to XML. VerifyRsaKey: P is not prime. --VerifyRsaKey Failed. --FromRfc4716PublicKey --ChilkatLog

Source=EdeSample StackTrace: at EdeSample.Program.Main(String[] args) in c:Usersedahl.NWPSCDocumentsVisual Studio 2012ProjectsEdeSampleEdeSampleProgram.cs:line 80 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException:

link

answered May 08 '13 at 16:46

Erik's gravatar image

Erik
6112

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×200
×89
×47

Asked: May 07 '13 at 16:09

Seen: 2,008 times

Last updated: May 08 '13 at 18:17

powered by OSQA