Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
606f6e21
Unverified
Commit
606f6e21
authored
Sep 09, 2019
by
Etienne Samson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cert: move cert enums & struct to its own header
parent
8bf0f7eb
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
133 additions
and
101 deletions
+133
-101
include/git2.h
+1
-0
include/git2/cert.h
+127
-0
include/git2/proxy.h
+3
-1
include/git2/transport.h
+1
-52
include/git2/types.h
+1
-48
No files found.
include/git2.h
View file @
606f6e21
...
...
@@ -15,6 +15,7 @@
#include "git2/blame.h"
#include "git2/branch.h"
#include "git2/buffer.h"
#include "git2/cert.h"
#include "git2/checkout.h"
#include "git2/cherrypick.h"
#include "git2/clone.h"
...
...
include/git2/cert.h
0 → 100644
View file @
606f6e21
/*
* Copyright (C) the libgit2 contributors. All rights reserved.
*
* This file is part of libgit2, distributed under the GNU GPL v2 with
* a Linking Exception. For full terms see the included COPYING file.
*/
#ifndef INCLUDE_git_cert_h__
#define INCLUDE_git_cert_h__
#include "common.h"
/**
* @file git2/cert.h
* @brief Git certificate objects
* @defgroup git_cert Certificate objects
* @ingroup Git
* @{
*/
GIT_BEGIN_DECL
/**
* Type of host certificate structure that is passed to the check callback
*/
typedef
enum
git_cert_t
{
/**
* No information about the certificate is available. This may
* happen when using curl.
*/
GIT_CERT_NONE
,
/**
* The `data` argument to the callback will be a pointer to
* the DER-encoded data.
*/
GIT_CERT_X509
,
/**
* The `data` argument to the callback will be a pointer to a
* `git_cert_hostkey` structure.
*/
GIT_CERT_HOSTKEY_LIBSSH2
,
/**
* The `data` argument to the callback will be a pointer to a
* `git_strarray` with `name:content` strings containing
* information about the certificate. This is used when using
* curl.
*/
GIT_CERT_STRARRAY
,
}
git_cert_t
;
/**
* Parent type for `git_cert_hostkey` and `git_cert_x509`.
*/
struct
git_cert
{
/**
* Type of certificate. A `GIT_CERT_` value.
*/
git_cert_t
cert_type
;
};
/**
* Callback for the user's custom certificate checks.
*
* @param cert The host certificate
* @param valid Whether the libgit2 checks (OpenSSL or WinHTTP) think
* this certificate is valid
* @param host Hostname of the host libgit2 connected to
* @param payload Payload provided by the caller
* @return 0 to proceed with the connection, < 0 to fail the connection
* or > 0 to indicate that the callback refused to act and that
* the existing validity determination should be honored
*/
typedef
int
GIT_CALLBACK
(
git_transport_certificate_check_cb
)(
git_cert
*
cert
,
int
valid
,
const
char
*
host
,
void
*
payload
);
/**
* Type of SSH host fingerprint
*/
typedef
enum
{
/** MD5 is available */
GIT_CERT_SSH_MD5
=
(
1
<<
0
),
/** SHA-1 is available */
GIT_CERT_SSH_SHA1
=
(
1
<<
1
),
}
git_cert_ssh_t
;
/**
* Hostkey information taken from libssh2
*/
typedef
struct
{
git_cert
parent
;
/**< The parent cert */
/**
* A hostkey type from libssh2, either
* `GIT_CERT_SSH_MD5` or `GIT_CERT_SSH_SHA1`
*/
git_cert_ssh_t
type
;
/**
* Hostkey hash. If type has `GIT_CERT_SSH_MD5` set, this will
* have the MD5 hash of the hostkey.
*/
unsigned
char
hash_md5
[
16
];
/**
* Hostkey hash. If type has `GIT_CERT_SSH_SHA1` set, this will
* have the SHA-1 hash of the hostkey.
*/
unsigned
char
hash_sha1
[
20
];
}
git_cert_hostkey
;
/**
* X.509 certificate information
*/
typedef
struct
{
git_cert
parent
;
/**< The parent cert */
/**
* Pointer to the X.509 certificate data
*/
void
*
data
;
/**
* Length of the memory block pointed to by `data`.
*/
size_t
len
;
}
git_cert_x509
;
/** @} */
GIT_END_DECL
#endif
include/git2/proxy.h
View file @
606f6e21
...
...
@@ -8,6 +8,8 @@
#define INCLUDE_git_proxy_h__
#include "common.h"
#include "cert.h"
#include "cred.h"
GIT_BEGIN_DECL
...
...
@@ -67,7 +69,7 @@ typedef struct {
* connection to proceed. Returns 0 to allow the connection
* or a negative value to indicate an error.
*/
git_transport_certificate_check_cb
certificate_check
;
git_transport_certificate_check_cb
certificate_check
;
/**
* Payload to be provided to the credentials and certificate
...
...
include/git2/transport.h
View file @
606f6e21
...
...
@@ -10,6 +10,7 @@
#include "indexer.h"
#include "net.h"
#include "types.h"
#include "cert.h"
#include "cred.h"
/**
...
...
@@ -24,58 +25,6 @@ GIT_BEGIN_DECL
/** Signature of a function which creates a transport */
typedef
int
GIT_CALLBACK
(
git_transport_cb
)(
git_transport
**
out
,
git_remote
*
owner
,
void
*
param
);
/**
* Type of SSH host fingerprint
*/
typedef
enum
{
/** MD5 is available */
GIT_CERT_SSH_MD5
=
(
1
<<
0
),
/** SHA-1 is available */
GIT_CERT_SSH_SHA1
=
(
1
<<
1
),
}
git_cert_ssh_t
;
/**
* Hostkey information taken from libssh2
*/
typedef
struct
{
git_cert
parent
;
/**< The parent cert */
/**
* A hostkey type from libssh2, either
* `GIT_CERT_SSH_MD5` or `GIT_CERT_SSH_SHA1`
*/
git_cert_ssh_t
type
;
/**
* Hostkey hash. If type has `GIT_CERT_SSH_MD5` set, this will
* have the MD5 hash of the hostkey.
*/
unsigned
char
hash_md5
[
16
];
/**
* Hostkey hash. If type has `GIT_CERT_SSH_SHA1` set, this will
* have the SHA-1 hash of the hostkey.
*/
unsigned
char
hash_sha1
[
20
];
}
git_cert_hostkey
;
/**
* X.509 certificate information
*/
typedef
struct
{
git_cert
parent
;
/**< The parent cert */
/**
* Pointer to the X.509 certificate data
*/
void
*
data
;
/**
* Length of the memory block pointed to by `data`.
*/
size_t
len
;
}
git_cert_x509
;
/** @} */
GIT_END_DECL
...
...
include/git2/types.h
View file @
606f6e21
...
...
@@ -256,56 +256,9 @@ typedef int GIT_CALLBACK(git_transport_message_cb)(const char *str, int len, voi
/**
* Type of host certificate structure that is passed to the check callback
*/
typedef
enum
git_cert_t
{
/**
* No information about the certificate is available. This may
* happen when using curl.
*/
GIT_CERT_NONE
,
/**
* The `data` argument to the callback will be a pointer to
* the DER-encoded data.
*/
GIT_CERT_X509
,
/**
* The `data` argument to the callback will be a pointer to a
* `git_cert_hostkey` structure.
*/
GIT_CERT_HOSTKEY_LIBSSH2
,
/**
* The `data` argument to the callback will be a pointer to a
* `git_strarray` with `name:content` strings containing
* information about the certificate. This is used when using
* curl.
*/
GIT_CERT_STRARRAY
,
}
git_cert_t
;
/**
* Parent type for `git_cert_hostkey` and `git_cert_x509`.
*/
typedef
struct
{
/**
* Type of certificate. A `GIT_CERT_` value.
*/
git_cert_t
cert_type
;
}
git_cert
;
/**
* Callback for the user's custom certificate checks.
*
* @param cert The host certificate
* @param valid Whether the libgit2 checks (OpenSSL or WinHTTP) think
* this certificate is valid
* @param host Hostname of the host libgit2 connected to
* @param payload Payload provided by the caller
* @return 0 to proceed with the connection, < 0 to fail the connection
* or > 0 to indicate that the callback refused to act and that
* the existing validity determination should be honored
*/
typedef
int
GIT_CALLBACK
(
git_transport_certificate_check_cb
)(
git_cert
*
cert
,
int
valid
,
const
char
*
host
,
void
*
payload
);
typedef
struct
git_cert
git_cert
;
/**
* Opaque structure representing a submodule.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment