FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fetch doesn't seem to work with https urls. · Issue #322 · nodegit/nodegit · GitHub

Repository navigation

Fetch doesn't seem to work with https urls. #322

Description

I have cloned a github repo using https. Running the fetch example gives me:

/..../node_modules/nodegit-promise/node_modules/asap/asap.js:45
throw e;
^
Error: The SSL certificate is invalid

Which is probably a correct message, since I never created any SSL certificate. I will try this example using SSH, but I would like HTTPS to work aswel.

Activity

  1. johnhaley81 commented on Dec 8, 2014

    Collaborator

    There seems to be an issue with GitHub's cert being falsely flagged as invalid on OSX. You can bypass the check during clone like this:

    var url = "https://github.com/nodegit/test.git";
    var opts = { ignoreCertErrors: 1 };
    
    return Clone.clone(url, https, opts).then(function(repository) {
      assert.ok(repository instanceof Repository);
    });

    An unauthorized should return a different error.

    If that doesn't work for you feel free to re-open this issue.

  2. Athaphian commented on Dec 8, 2014

    Author

    Not really sure how to reopen an issue on github, but I have used the example 'clone.js' which uses the ignoreCertErrors flag. The error happens when I run the fetch example on the same repo.

  3. johnhaley81 commented on Dec 8, 2014

    Collaborator

    The button next to "Comment" should be "Reopen Issue" or "Reopen and comment".

    Ah! So this is only during fetch and clone is fine. Ok so fetch needs the same flag but it's set differently inside of libgit2. Luckily it's pretty easy with the convenience function:

    var nodegit = require('nodegit');
    
    nodegit.Repository.open("path/to/repo/.git").then(function(repo) {
      return repo.fetch("origin", {
        credentials: function(url, userName) {
          return nodegit.Cred.sshKeyFromAgent(userName);
        },
        true /* ignoreCertErrors */
      });
    });
  4. johnhaley81 commented on Dec 8, 2014

    Collaborator

    One more note. This flag is set on the remote object and will persist on that object. If you make a new remote you'll have to reset that flag.

  5. Athaphian commented on Dec 8, 2014

    Author

    I don't think that is correct, since that code example does not compile..

  6. reopened this on Dec 8, 2014
  7. maxkorp commented on Dec 8, 2014

    Collaborator

    Reopened this for you, Athaphian. FYI, the reopen button is usually under the text input, next to "comment".

  8. Athaphian commented on Dec 8, 2014

    Author

    Thanx maxkorp, the button was not there. Now there is a button 'Close and comment'.

  9. maxkorp commented on Dec 8, 2014

    Collaborator

    Interesting. I'll take a look through the repo permissions... Thanks for the heads up.

  10. Athaphian commented on Dec 8, 2014

    Author

    I extracted all the relevant code from my project to make a working example, using one of my public repo's here on github:

    var nodegit = require('nodegit'),
        path = require('path');
    
    var tmp = new Date().getTime(),
        clonePath = path.resolve(__dirname, './clones/' + tmp),
        gitPath = path.resolve(__dirname, './clones/' + tmp + '/.git');
    
    var performFetch = function () {
    
      nodegit.Repository
    
        // Open the specified directory
          .open(gitPath).then(function (repo) {
    
            return repo.fetch("origin", {
              credentials: function (url, userName) {
                return nodegit.Cred.sshKeyFromAgent(userName);
              }
            });
    
          })
    
          .done(function () {
            console.log('Done fetching.');
          });
    };
    
    nodegit.Clone.clone('https://github.com/Athaphian/grunt-websocket.git', clonePath,
        {ignoreCertErrors: 1})
        .done(function () {
          console.log('Done cloning.');
          performFetch();
        });

    This code results in:

    Done cloning.

    /.../node_modules/nodegit-promise/node_modules/asap/asap.js:45
    throw e;
    ^
    Error: The SSL certificate is invalid

  11. johnhaley81 commented on Dec 8, 2014

    Collaborator
    var nodegit = require('nodegit');
    
    nodegit.Repository.open("path/to/repo/.git").then(function(repo) {
      return repo.fetch("origin", {
        credentials: function(url, userName) {
          return nodegit.Cred.sshKeyFromAgent(userName);
        }
      },
      true /* ignoreCertErrors */);
    });

    I miss aligned my brackets. I just ran that locally. In your code you'll just pass that same argument.

  12. Athaphian commented on Dec 8, 2014

    Author

    Ok that didn't give me an error, I will now check to see if the fetch really works..

  13. johnhaley81 commented on Dec 8, 2014

    Collaborator

    TIL if a repo owner closes an issue then the issue creator can't reopen it.

    http://stackoverflow.com/questions/21333654/how-to-re-open-an-issue-in-github

  14. Athaphian commented on Dec 8, 2014

    Author

    Good to know.

    With that 'true' in the correct place, it all works now. Thanks :)

  15. johnhaley81 commented on Dec 8, 2014

    Collaborator

    Great! Glad to hear it :)

  16. added a commit that references this issue on May 17, 2015
  17. tjcarroll11 commented on Aug 15, 2017

    Also want to note that I randomly ran into this error on a CentOS machine and found that setting

    certificateCheck: function() {
          return 1;
    }
    

    on the remote connection options cured it.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL