• Stars
    star
    176
  • Rank 216,987 (Top 5 %)
  • Language
    C
  • Created almost 12 years ago
  • Updated almost 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An example https client and server using OpenSSL and libevent, for the purpose of discussing some issues that came up on the libevent mailing list. This was just a one-off that I'm not maintaining, but I'm happy to accept pull requests.

This is probably not what you are looking for

Understandably, given that the name of the repository is https-example, I believe that a lot of people are coming here expecting to find an example of how to write an https server and/or client using libevent and OpenSSL.

Instead, this was something I threw together in 2013 as an example of a problem I was having when writing an https client and server using libevent and OpenSSL. I only posted it so I could discuss it on the libevent mailing list. I've kept it up in case it is useful to someone reading the mailing list archives, and because a number of people have starred or forked the repository.

If you're looking for an https client using libevent and OpenSSL, I would recommend checking out the example that comes with libevent. If you're looking for an https server using libevent and OpenSSL, I don't know of one to recommend. You might want to try asking on the libevent mailing list.

If you still want to look at the code in this repository, beware that the client and server are written to work together. The server only responds to a particular POST request generated by the client. (This is because this example is a simplified version of some programs I was writing at the time.) So if you want a general-purpose server, you'll need to modify it to respond to GET requests, at the very least.

Original README

ppelletier@chives:~/src/https-example$ uname -a
Linux chives 2.6.32-34-generic #77-Ubuntu SMP Tue Sep 13 19:39:17 UTC 2011 x86_64 GNU/Linux

start the server:

ppelletier@chives:~/src/https-example$ ./https-server
Using OpenSSL version "OpenSSL 1.0.1c 10 May 2012"
and libevent version "2.1.2-alpha-dev"
Loading certificate chain from 'server-certificate-chain.pem'
and private key from 'server-private-key.pem'
Listening on 0.0.0.0:8421

run the client... it works!

ppelletier@chives:~/src/https-example$ ./https-client
Using OpenSSL version "OpenSSL 1.0.1c 10 May 2012"
and libevent version "2.1.2-alpha-dev"
https server 'localhost' has this certificate, which looks good to me:
/C=US/ST=CA/L=Los Angeles/O=Oblong Industries/OU=Plasma/CN=localhost
server said: Hi 127.0.0.1!  I liked your passcode.

do the same thing with curl instead of with the client:

ppelletier@chives:~/src/https-example$ curl -k -d 'passcode=R23' https://localhost:8421/
Hi 127.0.0.1!  I liked your passcode.

Now, change the "#if 1" on line 214 of https-client.c to "#if 0", to
get rid of the special hack that turns "localhost" into "127.0.0.1",
in order to avoid IPv6.  Here's what happens:

ppelletier@chives:~/src/https-example$ ./https-client
Using OpenSSL version "OpenSSL 1.0.1c 10 May 2012"
and libevent version "2.1.2-alpha-dev"
code=0  POST failed
server said:

Next, change the "#if 0" on line 100 of https-client.c to "#if 1", to
enable retries:

ppelletier@chives:~/src/https-example$ ./https-client
Using OpenSSL version "OpenSSL 1.0.1c 10 May 2012"
and libevent version "2.1.2-alpha-dev"
[warn] Epoll ADD(1) on fd 7 failed.  Old events were 0; read change was 1 (add); write change was 0 (none): Bad file descriptor
[warn] Epoll ADD(4) on fd 7 failed.  Old events were 0; read change was 0 (none); write change was 1 (add): Bad file descriptor
code=0  POST failed
socket error = Bad file descriptor (9)
server said: (null)

More Repositories

1

json65

A JSON parser written in 6502 assembly language.
C
241
star
2

FeatherWing-template-KiCad

A KiCad 5 template for making a FeatherWing board.
HTML
29
star
3

esp-opc-server

Open Pixel Control server for ESP8266
C++
15
star
4

hs-wiringPi

A Haskell binding to the wiringPi library, for using GPIO on the Raspberry Pi.
Haskell
14
star
5

jsw-libs

Data structure libraries in C.
C
9
star
6

normalization-insensitive

A Haskell package based on the case-insensitive package, but for Unicode normalization instead of case.
Haskell
9
star
7

McLabel

Create labels for your McMaster-Carr bags, based on your McMaster-Carr receipt.
Haskell
8
star
8

NeoBit

KiCad files for a board that lets you hook up NeoPixels to a BBC micro:bit. The board also has a couple of slide potentiometers for input.
6
star
9

A2JoystickAdapter

A simple board to connect a 16-pin Apple II joystick to the 9-pin connector on the back of Apple IIe and later computers.
6
star
10

mercuryapi-corrections

some small patches to ThingMagic's Mercury API
C
5
star
11

hs-mercury-api

Haskell binding to Mercury API for ThingMagic RFID readers
C
4
star
12

footprint-to-script

Convert a KiCad footprint to a Python script
Haskell
4
star
13

whence

A command-line program to determine where a file was downloaded from, based on extended attributes.
C
4
star
14

rs-embedded-fish

An animated fish tank program written in Rust that runs on Longan Nano boards
Rust
4
star
15

hs-opc-client

A simple example of how to talk to an Open Pixel Control server from Haskell.
Haskell
4
star
16

dalvik-explorer

Some changes I've made to the "Dalvik Explorer" Android app, which I imported from subversion from its Google Code home page at https://code.google.com/p/enh/
Java
4
star
17

powermate

Read events from a Griffin PowerMate USB from Haskell, and control the LED.
Haskell
3
star
18

inty-midi

Convert MIDI files into IntyBASIC code for use on the Intellivision game console.
Haskell
3
star
19

avr-arduino-kicad

KiCad libraries and templates for AVR microcontrollers with a pinout that matches Arduino.
HTML
3
star
20

butterfly-hw

KiCad and Gerber files for a nightlight shaped like a butterfly.
2
star
21

TreeOrnament

A circuit board Christmas ornament, shaped like a tree, designed with KiCad.
2
star
22

pi-lcd

Control an Adafruit character LCD+keypad kit on a Raspberry Pi from Haskell
Haskell
2
star
23

hawiki

Mediawiki skin for Haskell Wiki
CSS
2
star
24

hourglass-test

reproduce a bug I'm seeing in hourglass on Raspberry Pi
Haskell
1
star
25

frege-on-android

An example of how to use Frege on Android.
Perl
1
star
26

ButterflyChain

KiCad files for a chainable NeoPixel butterfly.
1
star
27

gnutls

for patches I am submitting back to gnutls
C
1
star
28

hs-opc-client-with-button

Cycle through different patterns of lights with the press of a button on Raspberry Pi.
Haskell
1
star
29

SpeakerAdapter

Puts a JST-PH connector on the "Music Maker FeatherWing with Amp" instead of terminal blocks.
1
star
30

xml-notepad-for-mono

My attempt to port Microsoft's XML Notepad to run on Mono
C#
1
star
31

lifx-table-scraper

Scrape the product table from LIFX documentation and produce easy-to-consume JSON.
Haskell
1
star
32

diagram-pins

generates a diagram of pin numbers for the Raspberry Pi
Haskell
1
star
33

hs-wiringPi-test-board

KiCad design for a Raspberry Pi add-on board for testing the Haskell binding for wiringPi
1
star
34

host-vfy

This is six classes extracted from Apache Httpcomponents to make a tiny, self-contained library of implmentations of the HostnameVerifier interface.
Java
1
star
35

hs-powermate

Read events from a Griffin PowerMate USB from Haskell, and control the LED.
Haskell
1
star