Skip to content

Commit 68cfb58

Browse files
authored
Merge pull request libgit2#5223 from tiennou/fix/transport-header-split
Circular header splitting
2 parents c97cf08 + 71ca3dc commit 68cfb58

File tree

16 files changed

+570
-448
lines changed

16 files changed

+570
-448
lines changed

docs/changelog.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
v0.28 + 1
22
---------
33

4+
### Breaking API changes
5+
6+
* The "private" implementation details of the `git_cred` structure have been
7+
moved to a dedicated `git2/sys/cred.h` header, to clarify that the underlying
8+
structures are only provided for custom transport implementers.
9+
The breaking change is that the `username` member of the underlying struct
10+
is now hidden, and a new `git_cred_get_username` function has been provided.
11+
412
### Breaking CMake configuration changes
513

614
* The CMake option to use a system http-parser library, instead of the

include/git2.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@
1515
#include "git2/blame.h"
1616
#include "git2/branch.h"
1717
#include "git2/buffer.h"
18+
#include "git2/cert.h"
1819
#include "git2/checkout.h"
1920
#include "git2/cherrypick.h"
2021
#include "git2/clone.h"
2122
#include "git2/commit.h"
2223
#include "git2/common.h"
2324
#include "git2/config.h"
25+
#include "git2/cred.h"
2426
#include "git2/deprecated.h"
2527
#include "git2/describe.h"
2628
#include "git2/diff.h"

include/git2/cert.h

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
/*
2+
* Copyright (C) the libgit2 contributors. All rights reserved.
3+
*
4+
* This file is part of libgit2, distributed under the GNU GPL v2 with
5+
* a Linking Exception. For full terms see the included COPYING file.
6+
*/
7+
#ifndef INCLUDE_git_cert_h__
8+
#define INCLUDE_git_cert_h__
9+
10+
#include "common.h"
11+
12+
/**
13+
* @file git2/cert.h
14+
* @brief Git certificate objects
15+
* @defgroup git_cert Certificate objects
16+
* @ingroup Git
17+
* @{
18+
*/
19+
GIT_BEGIN_DECL
20+
21+
/**
22+
* Type of host certificate structure that is passed to the check callback
23+
*/
24+
typedef enum git_cert_t {
25+
/**
26+
* No information about the certificate is available. This may
27+
* happen when using curl.
28+
*/
29+
GIT_CERT_NONE,
30+
/**
31+
* The `data` argument to the callback will be a pointer to
32+
* the DER-encoded data.
33+
*/
34+
GIT_CERT_X509,
35+
/**
36+
* The `data` argument to the callback will be a pointer to a
37+
* `git_cert_hostkey` structure.
38+
*/
39+
GIT_CERT_HOSTKEY_LIBSSH2,
40+
/**
41+
* The `data` argument to the callback will be a pointer to a
42+
* `git_strarray` with `name:content` strings containing
43+
* information about the certificate. This is used when using
44+
* curl.
45+
*/
46+
GIT_CERT_STRARRAY,
47+
} git_cert_t;
48+
49+
/**
50+
* Parent type for `git_cert_hostkey` and `git_cert_x509`.
51+
*/
52+
struct git_cert {
53+
/**
54+
* Type of certificate. A `GIT_CERT_` value.
55+
*/
56+
git_cert_t cert_type;
57+
};
58+
59+
/**
60+
* Callback for the user's custom certificate checks.
61+
*
62+
* @param cert The host certificate
63+
* @param valid Whether the libgit2 checks (OpenSSL or WinHTTP) think
64+
* this certificate is valid
65+
* @param host Hostname of the host libgit2 connected to
66+
* @param payload Payload provided by the caller
67+
* @return 0 to proceed with the connection, < 0 to fail the connection
68+
* or > 0 to indicate that the callback refused to act and that
69+
* the existing validity determination should be honored
70+
*/
71+
typedef int GIT_CALLBACK(git_transport_certificate_check_cb)(git_cert *cert, int valid, const char *host, void *payload);
72+
73+
/**
74+
* Type of SSH host fingerprint
75+
*/
76+
typedef enum {
77+
/** MD5 is available */
78+
GIT_CERT_SSH_MD5 = (1 << 0),
79+
/** SHA-1 is available */
80+
GIT_CERT_SSH_SHA1 = (1 << 1),
81+
} git_cert_ssh_t;
82+
83+
/**
84+
* Hostkey information taken from libssh2
85+
*/
86+
typedef struct {
87+
git_cert parent; /**< The parent cert */
88+
89+
/**
90+
* A hostkey type from libssh2, either
91+
* `GIT_CERT_SSH_MD5` or `GIT_CERT_SSH_SHA1`
92+
*/
93+
git_cert_ssh_t type;
94+
95+
/**
96+
* Hostkey hash. If type has `GIT_CERT_SSH_MD5` set, this will
97+
* have the MD5 hash of the hostkey.
98+
*/
99+
unsigned char hash_md5[16];
100+
101+
/**
102+
* Hostkey hash. If type has `GIT_CERT_SSH_SHA1` set, this will
103+
* have the SHA-1 hash of the hostkey.
104+
*/
105+
unsigned char hash_sha1[20];
106+
} git_cert_hostkey;
107+
108+
/**
109+
* X.509 certificate information
110+
*/
111+
typedef struct {
112+
git_cert parent; /**< The parent cert */
113+
114+
/**
115+
* Pointer to the X.509 certificate data
116+
*/
117+
void *data;
118+
119+
/**
120+
* Length of the memory block pointed to by `data`.
121+
*/
122+
size_t len;
123+
} git_cert_x509;
124+
125+
/** @} */
126+
GIT_END_DECL
127+
#endif

0 commit comments

Comments
 (0)