NE_SOCK_HANDSHAKE(3)
π NE_SOCK_HANDSHAKE(3) β the neon API reference, but make it cute π
okay bestie, sit down, hydrate, and let me tell you about the SSL socket functions in the neon API. yes this is <ne_socket.h> business. yes it's giving serious. no you're not gonna be lost, i gotchu. π«Ά
β¨ NAME β¨
ne_sock_handshake, ne_sock_sessid, ne_sock_cipher, ne_sock_getproto, ne_sock_getcert, ne_ssl_check_certificate β the SSL socket functions. that's the whole squad. π
πΈ SYNOPSIS πΈ
#include <ne_socket.h>
int ne_sock_handshake(ne_socket *sock, ne_ssl_context *ctx,
const char *hostname, unsigned int flags);
int ne_sock_sessid(ne_socket *sock, unsigned char *buf, size_t *buflen);
char *ne_sock_cipher(ne_socket *sock);
enum ne_ssl_protocol ne_sock_getproto(ne_socket *sock);
ne_ssl_certificate *ne_sock_getcert(ne_socket *sock,
ne_ssl_context *ctx);
int ne_ssl_check_certificate(ne_ssl_context *ctx, ne_socket *sock,
const char *hostname,
const ne_inet_addr *address,
const ne_ssl_certificate *cert,
unsigned int flags, int *failures);
look at all those arguments. main character energy fr fr. β¨
π¦ DESCRIPTION π¦
ne_sock_handshake kicks off an SSL handshake on the socket sock, using the SSL context ctx. and here's the tea: if hostname is non-NULL, it gets used as the Server Name Indication (SNI) hint. as for flags? it must be zero. that's it. no wiggle room. π«
ne_sock_sessid goes and grabs the session ID of the current SSL session. how it behaves depends on buf, so pay attention bestie:
- if
bufis non-NULL, then on success it copies at most*buflenbytes intobuf, and sets*buflento the exact number of bytes it copied. - if
bufisNULL, then on success it just sets*buflento the length of the session ID. no copying, just vibes and math. π
ne_sock_cipher hands you back a human-readable name of the SSL/TLS cipher used for the connection β or NULL if there isn't one. lowkey important: the format of this string is not meant to be fixed or parseable, it's informational only. do not build a parser on top of it, i'm begging. π the return value is a NUL-terminated malloc-allocated string, so the caller has to free it. no leaving it lying around.
ne_sock_getproto returns the SSL/TLS protocol version that's in use for the socket sock β or NE_SSL_PROTO_UNSPEC if SSL/TLS isn't even in use for that socket. simple as that. π
ne_sock_getcert returns the server certificate for the socket. boom. done.
ne_ssl_check_certificate checks the identity of a server certificate against the hostname or address used to establish the connection, following the rules laid out in RFC 2818[1] and RFC 3280[2]. here's how the matching works:
- either
hostnameoraddresscan be non-NULLβ whichever one was used to identify the server when the SSL connection was established. - if both are
NULL, matching will fail, but the*identityoutput parameter will still be set. (yes, it still gets set. it's giving "we tried". π« ) flagsmust be zero. again. zero. π
and if verification fails? the failure reasons get stored in *failures as a binary OR of NE_SSL_* values. so you can go dig through them and figure out exactly what went wrong. iconic debugging era. π₯
π RETURN VALUE π
ne_sock_handshakeβ returns zero on success, or non-zero on error.ne_sock_sessidβ returns zero on success, or non-zero on error.ne_sock_cipherβ returns amalloc-allocated string on success, which must be freed by the caller, orNULLif no cipher is in use.ne_sock_getprotoβ returns the SSL/TLS protocol version, orNE_SSL_PROTO_UNSPEC.ne_sock_getcertβ returns the server certificate, orNULLon error.ne_ssl_check_certificateβ returns zero if the identity matches,1if the identity does not match, or less than zero if the certificate had no identity.
okay real talk for a sec: that last one is three different answers, so please actually check which one you got instead of just doing if (result) and calling it a day. π
β HISTORY β
receipts, because we love a timeline:
ne_sock_getprotois available in neon0.34.0and later.ne_sock_handshakeandne_sock_getcertare available in neon0.37.0and later.
so if you're on something ancient, that's why it's not linking, bestie. not your fault. π
π SEE ALSO π
go read that one next, it's the prequel. β¨
π COPYRIGHT π
Copyright Β© 2001-2026 Joe Orton
(we respect the author in this household. periodt. π)
π REFERENCES π
and that's the whole page, bestie!! π¦β¨ you now know SSL socket functions better than half the internet. slay.
this has been neon 0.37.1, dated 15 March 2026 β the manual page is NE_SOCK_HANDSHAKE(3) and yes she ate. π
πΈ mwah, go free your malloc-allocated strings. π«Ά
π¦ where this page comes from
- epel 10: neon-devel 0.37.1-4.el10_3 Β· LGPL-2.0-or-later AND GPL-2.0-or-later
- fedora 43: neon-devel 0.37.1-1.fc43 Β· LGPL-2.0-or-later AND GPL-2.0-or-later
- fedora 43: neon-devel 0.37.1-1.fc43 Β· LGPL-2.0-or-later AND GPL-2.0-or-later
- fedora 44: neon-devel 0.37.1-1.fc44 Β· LGPL-2.0-or-later AND GPL-2.0-or-later
- fedora 44: neon-devel 0.37.1-1.fc44 Β· LGPL-2.0-or-later AND GPL-2.0-or-later
- nixos 26.05: neon 0.37.1
- nixpkgs unstable: neon 0.37.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms