Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Abstract away the TLS stream implementation
Instead, provide git_tls_stream_new() to ask for the most appropriate encrypted stream and use it in our HTTP transport.
- Loading branch information
Showing
3 changed files
with
44 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
#include "openssl_stream.h" | ||
#include "stransport_stream.h" | ||
|
||
int git_tls_stream_new(git_stream **out, const char *host, const char *port) | ||
{ | ||
#ifdef GIT_SECURE_TRANSPORT | ||
return git_stransport_stream_new(out, host, port); | ||
#elif defined(GIT_SSL) | ||
return git_openssl_stream_new(out, host, port); | ||
#else | ||
giterr_set(GITERR_SSL, "there is no TLS stream available"); | ||
return -1; | ||
#endif | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* 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_tls_stream_h__ | ||
#define INCLUDE_tls_stream_h__ | ||
|
||
#include "git2/sys/stream.h" | ||
|
||
/** | ||
* Create a TLS stream with the most appropriate backend available for | ||
* the current platform. | ||
* | ||
* This allows us to ask for a SecureTransport or OpenSSL stream | ||
* according to being on general Unix vs OS X. | ||
*/ | ||
extern int git_tls_stream_new(git_stream **out, const char *host, const char *port); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters