Skip to content
Snippets Groups Projects
Commit 28f1c77d authored by Anton Wuerfel's avatar Anton Wuerfel
Browse files

Add git-http-timestamp helper tool


This commit adds the git-http-timestamp helper tool. It does all the
communication to a Time Stamping Authority via libcurl and passes the received
data to the caller via stdout.

Libcurl by default depends on GnuTLS, the new RFC3161 time-stamping
functionality depends on libcrypto (OpenSSL) as GnuTLS does not support RFC3161
time-stamps. The git-http-timestamp helper tool is introduced to avoid linking
OpenSSL and GnuTLS together in a single binary.

Signed-off-by: default avatarAnton Würfel <anton.wuerfel@fau.de>
Signed-off-by: default avatarPhillip Raffeck <phillip.raffeck@fau.de>
parent 3de54603
Branches
No related tags found
No related merge requests found
...@@ -70,6 +70,7 @@ ...@@ -70,6 +70,7 @@
/git-http-backend /git-http-backend
/git-http-fetch /git-http-fetch
/git-http-push /git-http-push
/git-http-timestamp
/git-imap-send /git-imap-send
/git-index-pack /git-index-pack
/git-init /git-init
......
...@@ -1116,6 +1116,9 @@ else ...@@ -1116,6 +1116,9 @@ else
BASIC_CFLAGS += -DEXPAT_NEEDS_XMLPARSE_H BASIC_CFLAGS += -DEXPAT_NEEDS_XMLPARSE_H
endif endif
endif endif
PROGRAM_OBJS += http-timestamp.o
PROGRAMS += git-http-timestamp$X
endif endif
IMAP_SEND_LDFLAGS += $(OPENSSL_LINK) $(OPENSSL_LIBSSL) $(LIB_4_CRYPTO) IMAP_SEND_LDFLAGS += $(OPENSSL_LINK) $(OPENSSL_LIBSSL) $(LIB_4_CRYPTO)
...@@ -2018,6 +2021,10 @@ git-remote-testsvn$X: remote-testsvn.o GIT-LDFLAGS $(GITLIBS) $(VCSSVN_LIB) ...@@ -2018,6 +2021,10 @@ git-remote-testsvn$X: remote-testsvn.o GIT-LDFLAGS $(GITLIBS) $(VCSSVN_LIB)
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS) \ $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS) \
$(VCSSVN_LIB) $(VCSSVN_LIB)
git-http-timestamp$X: http.o http-timestamp.o GIT-LDFLAGS $(GITLIBS)
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
$(CURL_LIBCURL) $(LIBS)
$(REMOTE_CURL_ALIASES): $(REMOTE_CURL_PRIMARY) $(REMOTE_CURL_ALIASES): $(REMOTE_CURL_PRIMARY)
$(QUIET_LNCP)$(RM) $@ && \ $(QUIET_LNCP)$(RM) $@ && \
ln $< $@ 2>/dev/null || \ ln $< $@ 2>/dev/null || \
......
...@@ -68,6 +68,7 @@ git-help ancillaryinterrogators ...@@ -68,6 +68,7 @@ git-help ancillaryinterrogators
git-http-backend synchingrepositories git-http-backend synchingrepositories
git-http-fetch synchelpers git-http-fetch synchelpers
git-http-push synchelpers git-http-push synchelpers
git-http-timestamp purehelpers
git-imap-send foreignscminterface git-imap-send foreignscminterface
git-index-pack plumbingmanipulators git-index-pack plumbingmanipulators
git-init mainporcelain init git-init mainporcelain init
......
#include "cache.h"
#include "strbuf.h"
#include "http.h"
static int obtain_tsr(struct strbuf *tsq, struct strbuf *tsr);
static void usage_and_die(const char *name);
static const char *config_tsa_url_key = "ts.tsaurl";
int main(int argc, const char *argv[])
{
struct strbuf tsr = STRBUF_INIT;
struct strbuf tsq = STRBUF_INIT;
int ret;
if (argc != 1)
usage_and_die(argv[0]);
if (strbuf_fread(&tsq, 1024, stdin) < 0) {
strbuf_release(&tsq);
return error(_("strbuf_fread failed: %s"), strerror(errno));
}
ret = obtain_tsr(&tsq, &tsr);
if (!ret)
write_in_full(fileno(stdout), tsr.buf, tsr.len);
strbuf_release(&tsr);
strbuf_release(&tsq);
return ret;
}
static int obtain_tsr(struct strbuf *tsq, struct strbuf *tsr)
{
struct strbuf content_type = STRBUF_INIT;
struct http_request_options options = {0};
char *config_tsa_url;
if (git_config_get_string(config_tsa_url_key, &config_tsa_url)) {
die(_("git config option '%s' must be set"),
config_tsa_url_key);
}
/* libcurl stuff */
http_init(NULL, config_tsa_url, 0);
strbuf_addstr(&content_type, "application/timestamp-query");
options.post_content_type = &content_type;
options.postfields = tsq;
if (http_get_strbuf(config_tsa_url, tsr, &options)) {
strbuf_release(&content_type);
return error(_("sending time-stamp query failed"));
}
strbuf_release(&content_type);
free(config_tsa_url);
http_cleanup();
return 0;
}
static void usage_and_die(const char *name)
{
fprintf(stderr, "Usage: %s\n\n", name);
fputs("Obtain a trusted time-stamp from the Time Stamping Authority\n"
"specified in configuration variable `ts.tsaurl` and write the\n"
"result to stdout.\n",
stderr);
exit(EXIT_FAILURE);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment