mirror of
https://github.com/openssl/openssl.git
synced 2025-02-11 14:22:43 +08:00
... and only *define* them in the source files that need them. Use DEFINE_OR_DECLARE which is set appropriately for internal builds and not non-deprecated builds. Deprecate stack-of-block Better documentation Move some ASN1 struct typedefs to types.h Update ParseC to handle this. Most of all, ParseC needed to be more consistent. The handlers are "recursive", in so far that they are called again and again until they terminate, which depends entirely on what the "massager" returns. There's a comment at the beginning of ParseC that explains how that works. {Richard Levtte} Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com> Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> (Merged from https://github.com/openssl/openssl/pull/10669)
69 lines
2.2 KiB
C
69 lines
2.2 KiB
C
/*
|
|
* Copyright 2007-2020 The OpenSSL Project Authors. All Rights Reserved.
|
|
* Copyright Nokia 2007-2019
|
|
* Copyright Siemens AG 2015-2019
|
|
*
|
|
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
|
* this file except in compliance with the License. You can obtain a copy
|
|
* in the file LICENSE in the source distribution or at
|
|
* https://www.openssl.org/source/license.html
|
|
*/
|
|
|
|
#include <string.h>
|
|
#include <stdio.h>
|
|
|
|
#include <openssl/asn1t.h>
|
|
#include <openssl/http.h>
|
|
#include "internal/sockets.h"
|
|
|
|
#include "openssl/cmp.h"
|
|
#include "cmp_local.h"
|
|
|
|
/* explicit #includes not strictly needed since implied by the above: */
|
|
#include <ctype.h>
|
|
#include <fcntl.h>
|
|
#include <stdlib.h>
|
|
#include <openssl/bio.h>
|
|
#include <openssl/buffer.h>
|
|
#include <openssl/cmp.h>
|
|
#include <openssl/err.h>
|
|
|
|
DEFINE_STACK_OF(CONF_VALUE)
|
|
|
|
/*
|
|
* Send the PKIMessage req and on success return the response, else NULL.
|
|
* Any previous error queue entries will likely be removed by ERR_clear_error().
|
|
*/
|
|
OSSL_CMP_MSG *OSSL_CMP_MSG_http_perform(OSSL_CMP_CTX *ctx,
|
|
const OSSL_CMP_MSG *req)
|
|
{
|
|
char server_port[32] = { '\0' };
|
|
STACK_OF(CONF_VALUE) *headers = NULL;
|
|
const char *const content_type_pkix = "application/pkixcmp";
|
|
OSSL_CMP_MSG *res;
|
|
|
|
if (ctx == NULL || req == NULL) {
|
|
CMPerr(0, CMP_R_NULL_ARGUMENT);
|
|
return NULL;
|
|
}
|
|
|
|
if (!X509V3_add_value("Pragma", "no-cache", &headers))
|
|
return NULL;
|
|
|
|
if (ctx->serverPort != 0)
|
|
BIO_snprintf(server_port, sizeof(server_port), "%d", ctx->serverPort);
|
|
|
|
res = (OSSL_CMP_MSG *)
|
|
OSSL_HTTP_post_asn1(ctx->server, server_port, ctx->serverPath,
|
|
OSSL_CMP_CTX_get_http_cb_arg(ctx) != NULL,
|
|
ctx->proxy, ctx->no_proxy, NULL, NULL,
|
|
ctx->http_cb, OSSL_CMP_CTX_get_http_cb_arg(ctx),
|
|
headers, content_type_pkix,
|
|
(ASN1_VALUE *)req, ASN1_ITEM_rptr(OSSL_CMP_MSG),
|
|
0, 0, ctx->msg_timeout, content_type_pkix,
|
|
ASN1_ITEM_rptr(OSSL_CMP_MSG));
|
|
|
|
sk_CONF_VALUE_pop_free(headers, X509V3_conf_free);
|
|
return res;
|
|
}
|