Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error "tls-openssl.c", Error "make[1]: *** [Makefile:373: iksemel] Error 127", Error "iksemel.texi:4: unknown command `setcontentsaftertitlepage'" #56

Open
ndeso17 opened this issue Jun 22, 2024 · 0 comments

Comments

@ndeso17
Copy link

ndeso17 commented Jun 22, 2024

Solusi untuk Error "tls-openssl.c"
Merubah kode pada iksemel/src/tls-openssl.c menjadi :

#include "iksemel.h"

#ifdef HAVE_OPENSSL

#include <openssl/ssl.h>
#include <openssl/bio.h>

struct ikstls_data {
    SSL_CTX *ctx;
    SSL *ssl;
    ikstransport *trans;
    void *sock;
    int timeout;
};

static int init_done;

static int
my_bio_create (BIO *b)
{
    BIO_set_init(b, 1);
    BIO_set_data(b, NULL);
    BIO_set_flags(b, 0);
    return 1;
}

static int
my_bio_destroy (BIO *b)
{
    if (b == NULL) return 0;

    BIO_set_data(b, NULL);
    BIO_set_init(b, 0);
    BIO_set_flags(b, 0);
    return 1;
}

static int
my_bio_read (BIO *b, char *buf, int len)
{
    struct ikstls_data *data = (struct ikstls_data *) BIO_get_data(b);
    int ret;

    if (buf == NULL || len <= 0 || data == NULL) return 0;

    ret = data->trans->recv(data->sock, buf, len, data->timeout);
    BIO_clear_retry_flags(b);
    return ret;
}

static int
my_bio_write (BIO *b, const char *buf, int len)
{
    struct ikstls_data *data = (struct ikstls_data *) BIO_get_data(b);
    int ret;

    if (buf == NULL || len <= 0 || data == NULL) return 0;

    ret = data->trans->send(data->sock, buf, len);
    BIO_clear_retry_flags(b);
    return ret;
}

static long
my_bio_ctrl (BIO *b, int cmd, long num, void *ptr)
{
    if (cmd == BIO_CTRL_FLUSH) {
        return 1;
    }
    return 0;
}

static int
my_bio_gets (BIO *b, char *buf, int len)
{
    return -1;
}

static int
my_bio_puts (BIO *b, const char *str)
{
    return my_bio_write(b, str, strlen(str));
}

static BIO_METHOD *my_bio_method = NULL;

static int
tls_handshake (struct ikstls_data **datap, ikstransport *trans, void *sock)
{
    struct ikstls_data *data;
    BIO *bio;

    *datap = NULL;

    data = iks_malloc(sizeof(*data));
    if (!data) return IKS_NOMEM;
    memset(data, 0, sizeof(*data));
    data->trans = trans;
    data->sock = sock;
    data->timeout = -1;

    if (!init_done) {
        SSL_library_init();
        OpenSSL_add_all_algorithms();
        SSL_load_error_strings();
        init_done = 1;
    }

    data->ctx = SSL_CTX_new(SSLv23_client_method());
    if (!data->ctx) {
        iks_free(data);
        return IKS_NOMEM;
    }

    data->ssl = SSL_new(data->ctx);
    if (!data->ssl) {
        iks_free(data);
        SSL_CTX_free(data->ctx);
        return IKS_NOMEM;
    }

    if (!my_bio_method) {
        my_bio_method = BIO_meth_new(BIO_TYPE_SOURCE_SINK, "iksemel transport");
        BIO_meth_set_write(my_bio_method, my_bio_write);
        BIO_meth_set_read(my_bio_method, my_bio_read);
        BIO_meth_set_puts(my_bio_method, my_bio_puts);
        BIO_meth_set_gets(my_bio_method, my_bio_gets);
        BIO_meth_set_ctrl(my_bio_method, my_bio_ctrl);
        BIO_meth_set_create(my_bio_method, my_bio_create);
        BIO_meth_set_destroy(my_bio_method, my_bio_destroy);
    }

    bio = BIO_new(my_bio_method);
    BIO_set_data(bio, (void *)data);
    SSL_set_bio(data->ssl, bio, bio);
    if (SSL_connect(data->ssl) < 0) {
        SSL_free(data->ssl);
        SSL_CTX_free(data->ctx);
        iks_free(data);
        return IKS_NET_TLSFAIL;
    }

    *datap = data;
    return IKS_OK;
}

static int
tls_send (struct ikstls_data *data, const char *buf, size_t size)
{
    int r;

    r = SSL_write(data->ssl, buf, size);
    switch (SSL_get_error(data->ssl, r)) {
        case SSL_ERROR_NONE:
            return IKS_OK;
        default:
            return IKS_NET_RWERR;
    }
}

static int
tls_recv (struct ikstls_data *data, char *buf, size_t size, int timeout)
{
    int r;

    data->timeout = timeout;
    r = SSL_read(data->ssl, buf, size);
    switch (SSL_get_error(data->ssl, r)) {
        case SSL_ERROR_NONE:
            return IKS_OK;
        default:
            return IKS_NET_RWERR;
    }
}

static void
tls_terminate(struct ikstls_data *data)
{
    SSL_free(data->ssl);
    SSL_CTX_free(data->ctx);
    iks_free(data);
}

ikstls iks_default_tls = {
    tls_handshake,
    tls_send,
    tls_recv,
    tls_terminate
};

#endif

Solusi untuk Error "make[1]: *** [Makefile:373: iksemel] Error 127" :
sudo apt install texinfo

Solusi untuk iksemel.texi:4: unknown command `setcontentsaftertitlepage' :
Hapus kode sebelum baris (Copyright @copyright{} 2001-2003 G@"urer @"Ozen) pada iksemel/doc/iksemel.texi kemudian ganti dengan kode berikut :

@c %**start of header

@macro setcontentsaftertitlepage
@end macro

@setfilename iksemel
@setcontentsaftertitlepage
@settitle Iksemel Programmers Manual
@set VERSION 1.2
@c %**end of header

@titlepage
@title iksemel programmers manual
@subtitle A tutorial and API reference for the iksemel library @value{VERSION}
@page
@vskip 0pt plus 1filll

Tangkapan Layar Error "tls-openssl.c"
tls-openssl

Tangkapan Layar Error "make[1]: *** [Makefile:373: iksemel] Error 127"
texinfo

Tangkapan Layar Error "iksemel.texi:4: unknown command `setcontentsaftertitlepage'"
setcontentsaftertitlepage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant