Git Product home page Git Product logo

openssl-dtls-custom-bio's People

Contributors

stepheny avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

openssl-dtls-custom-bio's Issues

add comments

i think this lacks comments or functions descriptions and structures descriptions
code is really hard to understand

Support the standard openssl s_client program

Hi, I have been testing your dtls server with openssl s_client. Everything works well except that thers is no line ending at the end of the server's replying messages. So I've made some patches here:

liuqun@22a2a38

Example:
openssl s_client -dtls1_2 -CAfile root-ca.pem -cert client-cert.pem -key client-key.pem -connect 127.0.0.1:4433

CONNECTED(00000003)
Can't use SSL_get_servername
depth=1 CN = test_rootCA
verify return:1
depth=0 CN = test_server
verify return:1
---
Certificate chain
 0 s:CN = test_server
   i:CN = test_rootCA
 1 s:CN = test_rootCA
   i:CN = test_rootCA
---
Server certificate
-----BEGIN CERTIFICATE-----
MIICoDCCAYgCAQMwDQYJKoZIhvcNAQELBQAwFjEUMBIGA1UEAwwLdGVzdF9yb290
...
2wrpchpM/u1gNdRGKY3Gcc/dsow5gWFxA/bcs2Jj0tR2AX6r6hGwoyuRBEH3Y3bb
aR01kg==
-----END CERTIFICATE-----
subject=CN = test_server

issuer=CN = test_rootCA

---
No client certificate CA names sent
Client Certificate Types: RSA sign, DSA sign, ECDSA sign
Requested Signature Algorithms: ECDSA+SHA256:ECDSA+SHA384:ECDSA+SHA512:Ed25519:Ed448:RSA-PSS+SHA256:RSA-PSS+SHA384:RSA-PSS+SHA512:RSA-PSS+SHA256:RSA-PSS+SHA384:RSA-PSS+SHA512:RSA+SHA256:RSA+SHA384:RSA+SHA512:ECDSA+SHA224:ECDSA+SHA1:RSA+SHA224:RSA+SHA1:DSA+SHA224:DSA+SHA1:DSA+SHA256:DSA+SHA384:DSA+SHA512
Shared Requested Signature Algorithms: ECDSA+SHA256:ECDSA+SHA384:ECDSA+SHA512:Ed25519:Ed448:RSA-PSS+SHA256:RSA-PSS+SHA384:RSA-PSS+SHA512:RSA-PSS+SHA256:RSA-PSS+SHA384:RSA-PSS+SHA512:RSA+SHA256:RSA+SHA384:RSA+SHA512:ECDSA+SHA224:ECDSA+SHA1:RSA+SHA224:RSA+SHA1:DSA+SHA224:DSA+SHA1:DSA+SHA256:DSA+SHA384:DSA+SHA512
Peer signing digest: SHA256
Peer signature type: RSA-PSS
Server Temp Key: X25519, 253 bits
---
SSL handshake has read 3021 bytes and written 2343 bytes
Verification: OK
---
New, TLSv1.2, Cipher is ECDHE-RSA-AES256-GCM-SHA384
Server public key is 2048 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
SSL-Session:
    Protocol  : DTLSv1.2
    Cipher    : ECDHE-RSA-AES256-GCM-SHA384
    Session-ID: 54FC503C5851322664842BDF7F4F06ECB3139E1913AC877B0322F2F028999273
    Session-ID-ctx: 
    Master-Key: DA377AC501F5D5806E3514226A7FA66C384C864ED8A7148B640E9E1AACD487342CA01DFF0D04CE996AAF2DA9676AD8DA
    PSK identity: None
    PSK identity hint: None
    SRP username: None
    TLS session ticket lifetime hint: 7200 (seconds)
    TLS session ticket:
    0000 - ce ed 7e 24 b2 af 32 4d-45 63 73 01 3d 9e 1c 56   ..~$..2MEcs.=..V
    0010 - e6 ed ee e6 7f 18 e9 1b-7b 39 e6 0f 86 03 b1 e9   ........{9......
...
    0330 - e3 51 de 1c fc 91 02 35-6a a3 6b b6 f4 8e 97 ba   .Q.....5j.k.....
    0340 - bd 76 cf fa 05 1f 63 e3-10 d1 bc 14 74 7f 25 21   .v....c.....t.%!

    Start Time: 1560330310
    Timeout   : 7200 (sec)
    Verify return code: 0 (ok)
    Extended master secret: yes
---
hello, INET6: [::ffff:127.0.0.1]:38305
help
Unknown command! Currently my server supports the following commands:
  1. ping returns pong
  2. echo <some text> returns <some text>
  3. whoami returns client's address and port seen by server
  4. stats returns a list of server currently serving clients
  5. bc <some text> broadcast <some text> to all clients
You may try these commands youself and see how they work.
Good luck!
ping
pong
whoami
INET6: [::ffff:127.0.0.1]:38305
stats
users:
INET6: [::ffff:127.0.0.1]:38305
bc aaabbb
aaabbb
echo abcd
abcd

Hope it could be useful...
Happy hacking!

runtime crash when linked aganst libssl with SCTP feature enabled

RedHat's RHEL-8.0 has enabled the SCTP feature on OpenSSL 1.1.1 by default.

The BIO_s_custom_ctrl() method has a bug that it would crash on cmd 51 BIO_CTRL_DGRAM_SCTP_ADD_AUTH_KEY:

[liuqun@RHEL8]$ ./client 127.0.0.1:4433
SSL_CTX_load_verify_locations -> 1
SSL_CTX_set_default_verify_file -> 1
BIO_s_custom_create(BIO[0x0000000001DE1370])
BIO_s_custom_write(BIO[0x0000000001DE1370], buf[0x0000000001DFB6E0], dlen[219])
>> INET: 127.0.0.1:4433
  219 bytes sent
BIO_s_custom_read(BIO[0x0000000001DE1370], data[0x0000000001DF24A3], dlen[16717])
  probe peekmode 0
  data[0x00007FFEB7605248] queue: 0
<< 36 bytes
BIO_s_custom_read(BIO[0x0000000001DE1370], data[0x0000000001DF24A3], dlen[16717])
  probe peekmode 0
  data[0x00007FFEB7605248] queue: 1
  buf[0x0000000001DEC760]
BIO_s_custom_write(BIO[0x0000000001DE1370], buf[0x0000000001DFB6E0], dlen[227])
>> INET: 127.0.0.1:4433
  227 bytes sent
BIO_s_custom_read(BIO[0x0000000001DE1370], data[0x0000000001DF24A3], dlen[16717])
  probe peekmode 0
  data[0x00007FFEB7605248] queue: 0
<< 1500 bytes
BIO_s_custom_read(BIO[0x0000000001DE1370], data[0x0000000001DF24A3], dlen[16717])
  probe peekmode 0
  data[0x00007FFEB7605248] queue: 1
  buf[0x0000000001E1D5F0]
BIO_s_custom_read(BIO[0x0000000001DE1370], data[0x0000000001DF24A3], dlen[16717])
  probe peekmode 0
  data[0x00007FFEB7605248] queue: 0
<< 531 bytes
BIO_s_custom_read(BIO[0x0000000001DE1370], data[0x0000000001DF24A3], dlen[16717])
  probe peekmode 0
  data[0x00007FFEB7605248] queue: 1
  buf[0x0000000001E1DDD0]
BIO_s_custom_write(BIO[0x0000000001DE1370], buf[0x0000000001DFB6E0], dlen[1495])
>> INET: 127.0.0.1:4433
  1495 bytes sent
BIO_s_custom_ctrl(BIO[0x0000000001DE1370], cmd[51], larg[64], pargs[0x00007FFEB7605010])
  unknown cmd: 51
Trace/breakpoint trap (core dumped)

cmd 51 is BIO_CTRL_DGRAM_SCTP_ADD_AUTH_KEY:

See /usr/include/openssl/bio.h

# ifndef OPENSSL_NO_SCTP
/* SCTP stuff */
#  define BIO_CTRL_DGRAM_SCTP_ADD_AUTH_KEY                51
#  define BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY               52
#  define BIO_CTRL_DGRAM_SCTP_AUTH_CCS_RCVD               53
#  define BIO_CTRL_DGRAM_SCTP_GET_SNDINFO         60
#  define BIO_CTRL_DGRAM_SCTP_SET_SNDINFO         61
#  define BIO_CTRL_DGRAM_SCTP_GET_RCVINFO         62
#  define BIO_CTRL_DGRAM_SCTP_SET_RCVINFO         63
#  define BIO_CTRL_DGRAM_SCTP_GET_PRINFO                  64
#  define BIO_CTRL_DGRAM_SCTP_SET_PRINFO                  65
#  define BIO_CTRL_DGRAM_SCTP_SAVE_SHUTDOWN               70
# endif

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.