Find Jobs
Hire Freelancers

simple linux .c ssl connection file not working correctly

$10-30 USD

Completed
Posted almost 4 years ago

$10-30 USD

Paid on delivery
Hi We have this sslconnect.c Then we call it from other program with snprintf(sendbuffer,4096, "GET /[login to view URL] HTTP/1.0\r\n\r\n"); SSL_write(ssl, sendbuffer, strlen(sendbuffer)); bzero(buffer,sizeof(buffer)); if (SSL_read(ssl, buffer, 2048) <= 0) { goto end; // disconnected } alarm(0); printf("What is ssl buffer: %s",buffer); But it seems no matter what it not getting reply data from remote web server. sslconnect.c * * When using sslconnect, you need to use SSL_write(ssl, buffer, length) instead of write(sock, buffer, length) and SSL_read(ssl, buffer, length) instead of read(sock, buffer, length). * When you are finished using the ssl connection call ssldisconnect(). */ #include <sys/types.h> #include <sys/socket.h> #include <netdb.h> #include <openssl/crypto.h> #include <openssl/ssl.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> /* these are global variables that you need to have declared whereever you use sslconnect */ int check; int sock; SSL *ssl; SSL_CTX *ssl_ctx; void sslconnect(int connectport, char *scanip) { struct addrinfo hints, *res; char strport[16]; /* initialize SSL context */ SSL_library_init(); ssl_ctx = SSL_CTX_new(SSLv23_client_method()); ssl = SSL_new(ssl_ctx); memset(&hints, 0, sizeof hints); hints.ai_family = AF_INET; hints.ai_socktype = SOCK_STREAM; sprintf(strport, "%d", connectport); getaddrinfo(scanip, strport, &hints, &res); sock = socket(res->ai_family, res->ai_socktype, res->ai_protocol); if(connect(sock, res->ai_addr, res->ai_addrlen) == -1) { check = -1; return; } /* initialize SSL connection */ SSL_set_fd(ssl, sock); if(SSL_connect(ssl) == -1) { check = -1; close(sock); return; } check = 1; return; } void ssldisconnect() { /* cleanup */ SSL_shutdown(ssl); close(sock); SSL_free(ssl); SSL_CTX_free(ssl_ctx); }
Project ID: 25856318

About the project

3 proposals
Remote project
Active 4 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
Awarded to:
User Avatar
Hello I have over 20 years of experience with C and C++ including working with OpenSSL, Linux and Windows.
$33 USD in 1 day
4.9 (1883 reviews)
8.0
8.0
3 freelancers are bidding on average $19 USD for this job
User Avatar
Hello there, I understand your project description. I am highly interested to work on this project. I can do this work perfectly for you. I have all the skills that you need for your work. I will do this project as soon as possible for you. We can discuss more in chat about your work. So, I will look forward to hearing from you. Thank you. Stay home, be safe, and take care.
$10 USD in 2 days
0.0 (0 reviews)
0.0
0.0
User Avatar
I can fix it in short.........................................................................................
$15 USD in 1 day
0.0 (0 reviews)
0.0
0.0

About the client

Flag of SWEDEN
Copenhagen K, Sweden
5.0
61
Payment method verified
Member since Oct 26, 2008

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.