Skip to content

Commit 3695fda

Browse files
committed
Fix documentation and uses of certificateCheck since it works correctly
certificateCheck used to require passing 1 to ignore certificate failures. Now we need to pass 0 to inform libgit2 that the certificate was deemed valid.
1 parent 5964ef1 commit 3695fda

File tree

12 files changed

+29
-65
lines changed

12 files changed

+29
-65
lines changed

examples/clone.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fse.remove(path).then(function() {
1414
certificateCheck: function() {
1515
// github will fail cert check on some OSX machines
1616
// this overrides that check
17-
return 1;
17+
return 0;
1818
}
1919
}
2020
}

examples/cloneFromGithubWith2Factor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var opts = {
2020
return nodegit.Cred.userpassPlaintextNew(token, "x-oauth-basic");
2121
},
2222
certificateCheck: function() {
23-
return 1;
23+
return 0;
2424
}
2525
}
2626
}

examples/pull.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ nodegit.Repository.open(path.resolve(__dirname, repoDir))
1616
return nodegit.Cred.sshKeyFromAgent(userName);
1717
},
1818
certificateCheck: function() {
19-
return 1;
19+
return 0;
2020
}
2121
}
2222
});

guides/cloning/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ to passthrough the certificate check.
8585
``` javascript
8686
cloneOptions.fetchOpts = {
8787
callbacks: {
88-
certificateCheck: function() { return 1; }
88+
certificateCheck: function() { return 0; }
8989
}
9090
};
9191
```

guides/cloning/gh-two-factor/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ to passthrough the certificate check.
101101
``` javascript
102102
cloneOptions.fetchOpts = {
103103
callbacks: {
104-
certificateCheck: function() { return 1; }
104+
certificateCheck: function() { return 0; }
105105
}
106106
};
107107
```
@@ -119,7 +119,7 @@ The `fetchOpts` object now looks like this:
119119
``` javascript
120120
cloneOptions.fetchOpts = {
121121
callbacks: {
122-
certificateCheck: function() { return 1; },
122+
certificateCheck: function() { return 0; },
123123
credentials: function() {
124124
return NodeGit.Cred.userpassPlaintextNew(GITHUB_TOKEN, "x-oauth-basic");
125125
}

guides/cloning/gh-two-factor/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ var cloneOptions = {};
2222
// with libgit2 being able to verify certificates from GitHub.
2323
cloneOptions.fetchOpts = {
2424
callbacks: {
25-
certificateCheck: function() { return 1; },
25+
certificateCheck: function() { return 0; },
2626
credentials: function() {
2727
return NodeGit.Cred.userpassPlaintextNew(GITHUB_TOKEN, "x-oauth-basic");
2828
}

guides/cloning/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ var cloneOptions = {};
1818
// with libgit2 being able to verify certificates from GitHub.
1919
cloneOptions.fetchOpts = {
2020
callbacks: {
21-
certificateCheck: function() { return 1; }
21+
certificateCheck: function() { return 0; }
2222
}
2323
};
2424

guides/cloning/ssh-with-agent/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ to passthrough the certificate check.
8383
``` javascript
8484
cloneOptions.fetchOpts = {
8585
callbacks: {
86-
certificateCheck: function() { return 1; }
86+
certificateCheck: function() { return 0; }
8787
}
8888
};
8989
```
@@ -102,7 +102,7 @@ The `fetchOpts` object now looks like this:
102102
``` javascript
103103
cloneOptions.fetchOpts = {
104104
callbacks: {
105-
certificateCheck: function() { return 1; },
105+
certificateCheck: function() { return 0; },
106106
credentials: function(url, userName) {
107107
return NodeGit.Cred.sshKeyFromAgent(userName);
108108
}

guides/cloning/ssh-with-agent/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ var cloneOptions = {};
1717
// with libgit2 being able to verify certificates from GitHub.
1818
cloneOptions.fetchOpts = {
1919
callbacks: {
20-
certificateCheck: function() { return 1; },
20+
certificateCheck: function() { return 0; },
2121

2222
// Credentials are passed two arguments, url and username. We forward the
2323
// `userName` argument to the `sshKeyFromAgent` function to validate

test/tests/clone.js

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ describe("Clone", function() {
4343
var opts = {
4444
fetchOpts: {
4545
callbacks: {
46-
certificateCheck: function() {
47-
return 1;
48-
}
46+
certificateCheck: () => 0
4947
}
5048
}
5149
};
@@ -202,9 +200,7 @@ describe("Clone", function() {
202200
var opts = {
203201
fetchOpts: {
204202
callbacks: {
205-
certificateCheck: function() {
206-
return 1;
207-
}
203+
certificateCheck: () => 0
208204
}
209205
}
210206
};
@@ -221,9 +217,7 @@ describe("Clone", function() {
221217
var opts = {
222218
fetchOpts: {
223219
callbacks: {
224-
certificateCheck: function() {
225-
return 1;
226-
},
220+
certificateCheck: () => 0,
227221
credentials: function(url, userName) {
228222
return NodeGit.Cred.sshKeyFromAgent(userName);
229223
}
@@ -243,9 +237,7 @@ describe("Clone", function() {
243237
var opts = {
244238
fetchOpts: {
245239
callbacks: {
246-
certificateCheck: function() {
247-
return 1;
248-
},
240+
certificateCheck: () => 0,
249241
credentials: function(url, userName) {
250242
return NodeGit.Cred.sshKeyNew(
251243
userName,
@@ -269,9 +261,7 @@ describe("Clone", function() {
269261
var opts = {
270262
fetchOpts: {
271263
callbacks: {
272-
certificateCheck: function() {
273-
return 1;
274-
},
264+
certificateCheck: () => 0,
275265
credentials: function(url, userName) {
276266
return NodeGit.Cred.sshKeyNew(
277267
userName,
@@ -296,9 +286,7 @@ describe("Clone", function() {
296286
var opts = {
297287
fetchOpts: {
298288
callbacks: {
299-
certificateCheck: function() {
300-
return 1;
301-
}
289+
certificateCheck: () => 0
302290
}
303291
}
304292
};
@@ -328,9 +316,7 @@ describe("Clone", function() {
328316
return Clone(url, clonePath, {
329317
fetchOpts: {
330318
callbacks: {
331-
certificateCheck: function() {
332-
return 1;
333-
},
319+
certificateCheck: () => 0,
334320
credentials: function() {
335321
if (firstPass) {
336322
firstPass = false;

0 commit comments

Comments
 (0)