(cert_i, valid, host, data)
| 536 | |
| 537 | @libgit2_callback |
| 538 | def _certificate_check_cb(cert_i, valid, host, data): |
| 539 | # We want to simulate what should happen if libgit2 supported pass-through |
| 540 | # for this callback. For SSH, 'valid' is always False, because it doesn't |
| 541 | # look at known_hosts, but we do want to let it through in order to do what |
| 542 | # libgit2 would if the callback were not set. |
| 543 | try: |
| 544 | is_ssh = cert_i.cert_type == C.GIT_CERT_HOSTKEY_LIBSSH2 |
| 545 | |
| 546 | # python's parsing is deep in the libraries and assumes an OpenSSL-owned cert |
| 547 | val = data.certificate_check(None, bool(valid), ffi.string(host)) |
| 548 | if not val: |
| 549 | return C.GIT_ECERTIFICATE |
| 550 | except Passthrough: |
| 551 | if is_ssh: |
| 552 | return 0 |
| 553 | elif valid: |
| 554 | return 0 |
| 555 | else: |
| 556 | return C.GIT_ECERTIFICATE |
| 557 | |
| 558 | return 0 |
| 559 | |
| 560 | |
| 561 | @libgit2_callback |
nothing calls this directly
no test coverage detected
searching dependent graphs…