Giter Club home page Giter Club logo

Comments (2)

mikeabdullah avatar mikeabdullah commented on July 17, 2024

OK, here we go:

[CK2FileManager URLWithPath:path relativeToURL:ftpServer]

Not the actual problem here, but could you try using the newer +URLWithPath:isDirectory:hostURL instead, please? I'd like to remove the older method at some point as it tends to get pretty confusing once user-entered URLs make it into the system.

[NSURL URLWithString:@"/Users/<myUserNameOnLocalMachine>/.ssh/id_rsa"]

You're passing a path here into a method that expects to receive a URL string. Suggest you want +fileURLWithPath: instead.

-(void)fileManager:(CK2FileManager *)manager operation:(CK2FileOperation *)operation didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(CK2AuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler

The first thing you ought to do in this method is test challenge.protectionSpace.authenticationMethod is NSURLAuthenticationMethodDefault. For SFTP we also issue another challenge to test if the server's public key is expected. For any protection spaces you don't want to customise the handling of, ask for the default behaviour.

[[challenge sender] useCredential:C forAuthenticationChallenge:challenge];

This approach is no longer supported; we're copying NSURLSession and you should call the completionHandler instead.

All this adds up to something like:

-(void)fileManager:(CK2FileManager *)manager operation:(CK2FileOperation *)operation
didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge
completionHandler:(void (^)(CK2AuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler
{
    if (![challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodDefault]) {
        completionHandler(CK2AuthChallengePerformDefaultHandling, nil);
        return;
    }

    NSURLCredential *cred = [NSURLCredential ck2_credentialWithUser:@"<username>"
                                                     publicKeyURL:nil
                                                    privateKeyURL:[NSURL fileURLWithPath:@"/Users/<myUserNameOnLocalMachine>/.ssh/id_rsa"]
                                                         password:nil
                                                      persistence:NSURLCredentialPersistenceForSession];
    completionHandler(CK2AuthChallengeUseCredential, cred);
}

from connectionkit.

RabbitMC avatar RabbitMC commented on July 17, 2024

WOW! Thanks a Lot! Its working fast and very well. Now I can do my stuff on this. Thank you very much. :)

from connectionkit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.