예제 #1
0
OCSP_REQ_CTX *OCSP_sendreq_new(BIO *io, char *path, OCSP_REQUEST *req,
								int maxline)
	{
	static const char post_hdr[] = "POST %s HTTP/1.0\r\n";

	OCSP_REQ_CTX *rctx;
	rctx = (OCSP_REQ_CTX*)OPENSSL_malloc(sizeof(OCSP_REQ_CTX));
	rctx->state = OHS_ERROR;
	rctx->mem = BIO_new(BIO_s_mem());
	rctx->io = io;
	rctx->asn1_len = 0;
	if (maxline > 0)
		rctx->iobuflen = maxline;
	else
		rctx->iobuflen = OCSP_MAX_LINE_LEN;
	rctx->iobuf = (unsigned char*)OPENSSL_malloc(rctx->iobuflen);
	if (!rctx->iobuf)
		return 0;
	if (!path)
		path = "/";

        if (BIO_printf(rctx->mem, post_hdr, path) <= 0)
		return 0;

	if (req && !OCSP_REQ_CTX_set1_req(rctx, req))
		return 0;

	return rctx;
	}
예제 #2
0
파일: ocsp.c 프로젝트: jymigeon/openiked
/* we got a connection to the ocsp responder */
int
ocsp_receive_fd(struct iked *env, struct imsg *imsg)
{
	struct iked_ocsp_entry	*ioe = NULL;
	struct iked_ocsp	*ocsp = NULL;
	struct iked_socket	*sock;
	char			*path = NULL;
	int			 ret = -1;

	log_debug("%s: received socket fd %d", __func__, imsg->fd);
	if ((ioe = TAILQ_FIRST(&env->sc_ocsp)) == NULL) {
		log_debug("%s: oops, no request for", __func__);
		close(imsg->fd);
		return (-1);
	}
	TAILQ_REMOVE(&env->sc_ocsp, ioe, ioe_entry);
	ocsp = ioe->ioe_ocsp;
	free(ioe);

	if ((sock = calloc(1, sizeof(*sock))) == NULL)
		fatal("ocsp_receive_fd: calloc sock");

	/* note that sock_addr is not set */
	sock->sock_fd = imsg->fd;
	sock->sock_env = env;
	ocsp->ocsp_sock = sock;

	/* fetch 'path' and 'fd' from imsg */
	if ((path = get_string(imsg->data, IMSG_DATA_SIZE(imsg))) == NULL)
		goto done;

	BIO_set_fd(ocsp->ocsp_cbio, imsg->fd, BIO_NOCLOSE);

	if ((ocsp->ocsp_req_ctx = OCSP_sendreq_new(ocsp->ocsp_cbio,
	    path, NULL, -1)) == NULL)
		goto done;
	if (!OCSP_REQ_CTX_set1_req(ocsp->ocsp_req_ctx, ocsp->ocsp_req))
		goto done;

	event_set(&sock->sock_ev, sock->sock_fd, EV_WRITE, ocsp_callback, ocsp);
	event_add(&sock->sock_ev, NULL);
	ret = 0;
 done:
	if (ret == -1)
		ocsp_validate_finish(ocsp, 0);	/* failed */
	free(path);
	return (ret);
}
예제 #3
0
파일: ocsp_ht.c 프로젝트: MiKTeX/miktex
OCSP_REQ_CTX *
OCSP_sendreq_new(BIO *io, const char *path, OCSP_REQUEST *req, int maxline)
{
	OCSP_REQ_CTX *rctx;

	rctx = malloc(sizeof(OCSP_REQ_CTX));
	if (rctx == NULL)
		return NULL;
	rctx->state = OHS_ERROR;
	if ((rctx->mem = BIO_new(BIO_s_mem())) == NULL) {
		free(rctx);
		return NULL;
	}
	rctx->io = io;
	rctx->asn1_len = 0;
	if (maxline > 0)
		rctx->iobuflen = maxline;
	else
		rctx->iobuflen = OCSP_MAX_LINE_LEN;
	rctx->iobuf = malloc(rctx->iobuflen);
	if (!rctx->iobuf) {
		BIO_free(rctx->mem);
		free(rctx);
		return NULL;
	}
	if (!path)
		path = "/";

	if (BIO_printf(rctx->mem, "POST %s HTTP/1.0\r\n", path) <= 0) {
		free(rctx->iobuf);
		BIO_free(rctx->mem);
		free(rctx);
		return NULL;
	}

	if (req && !OCSP_REQ_CTX_set1_req(rctx, req)) {
		free(rctx->iobuf);
		BIO_free(rctx->mem);
		free(rctx);
		return NULL;
	}

	return rctx;
}
예제 #4
0
OCSP_REQ_CTX *OCSP_sendreq_new(BIO *io, const char *path, OCSP_REQUEST *req,
			       int maxline)
	{

	OCSP_REQ_CTX *rctx = NULL;
	rctx = OCSP_REQ_CTX_new(io, maxline);
	if (!rctx)
		return NULL;

	if (!OCSP_REQ_CTX_http(rctx, "POST", path))
		goto err;

	if (req && !OCSP_REQ_CTX_set1_req(rctx, req))
		goto err;

	return rctx;
	
	err:
	OCSP_REQ_CTX_free(rctx);
	return NULL;
	}