SSL_CTX_SET_SRP_PASSWORD(3SSL)
π SSL_CTX_SET_SRP_PASSWORD π
okay bestie, so this is an OpenSSL 3SSL manual page, and it's a whole squad of functions β it's not just one. We got:
SSL_CTX_set_srp_usernameSSL_CTX_set_srp_passwordSSL_CTX_set_srp_strengthSSL_CTX_set_srp_cb_argSSL_CTX_set_srp_username_callbackSSL_CTX_set_srp_client_pwd_callbackSSL_CTX_set_srp_verify_param_callbackSSL_set_srp_server_paramSSL_set_srp_server_param_pwSSL_get_srp_gSSL_get_srp_NSSL_get_srp_usernameSSL_get_srp_userinfo
Their whole personality? SRP control operations. That's the vibe. β¨
β οΈ heads up before we even start: ALL of these functions are deprecated. Like, all of them. Every single one on this page. And the plot twist? there are no replacement functions at this time. So if you're starting fresh β iykyk. π
β¨ SYNOPSIS β¨
First, the include you literally always need:
#include <openssl/ssl.h>
The following functions have been deprecated since OpenSSL 3.0, and can be hidden entirely by defining OPENSSL_API_COMPAT with a suitable version value, see openssl_user_macros(7):
int SSL_CTX_set_srp_username(SSL_CTX *ctx, char *name);
int SSL_CTX_set_srp_password(SSL_CTX *ctx, char *password);
int SSL_CTX_set_srp_strength(SSL_CTX *ctx, int strength);
int SSL_CTX_set_srp_cb_arg(SSL_CTX *ctx, void *arg);
int SSL_CTX_set_srp_username_callback(SSL_CTX *ctx,
int (*cb) (SSL *s, int *ad, void *arg));
int SSL_CTX_set_srp_client_pwd_callback(SSL_CTX *ctx,
char *(*cb) (SSL *s, void *arg));
int SSL_CTX_set_srp_verify_param_callback(SSL_CTX *ctx,
int (*cb) (SSL *s, void *arg));
int SSL_set_srp_server_param(SSL *s, const BIGNUM *N, const BIGNUM *g,
BIGNUM *sa, BIGNUM *v, char *info);
int SSL_set_srp_server_param_pw(SSL *s, const char *user, const char *pass,
const char *grp);
BIGNUM *SSL_get_srp_g(SSL *s);
BIGNUM *SSL_get_srp_N(SSL *s);
char *SSL_get_srp_username(SSL *s);
char *SSL_get_srp_userinfo(SSL *s);
πΈ DESCRIPTION πΈ
Okay so first thing, and I cannot stress this enough: all of the functions described on this page are deprecated. There are no available replacement functions at this time. That's the whole tea. β
These functions give you access to SRP (Secure Remote Password) parameters β it's an alternate authentication mechanism for TLS. And the reason it's iconic? SRP lets you use usernames and passwords over unencrypted channels without revealing the password to an eavesdropper. Not a single crumb leaked. π«Ά SRP also supplies a shared secret at the end of the authentication sequence that can be used to generate encryption keys.
The SRP protocol, version 3 is specified in RFC 2945. SRP version 6 is described in RFC 5054 with applications to TLS authentication.
Now let's go function by function, because there's a LOT of them:
π The SSL_CTX_set_srp_* girlies
SSL_CTX_set_srp_username()β sets the SRP username forctx. This should be called on the client prior to creating a connection to the server. The length ofnamemust be shorter or equal to 255 characters. Keep it cute and keep it short. βοΈSSL_CTX_set_srp_password()β sets the SRP password forctx. This may be called on the client prior to creating a connection to the server. This overrides the effect ofSSL_CTX_set_srp_client_pwd_callback().SSL_CTX_set_srp_strength()β sets the SRP strength forctx. This is the minimal length of the SRP prime in bits. If not specified,1024is used. If not satisfied by the server key exchange the connection will be rejected. no notes, she's strict. πSSL_CTX_set_srp_cb_arg()β sets an extra parameter that will be passed to all following callbacks asarg. It's basically the little bag you hand to all your callback besties. πSSL_CTX_set_srp_username_callback()β sets the server side callback that is invoked when an SRP username is found in a ClientHello. The callback parameters are the SSL connections, a writable error flagadand the extra argumentargset bySSL_CTX_set_srp_cb_arg(). This callback should setup the server for the key exchange by callingSSL_set_srp_server_param()with the appropriate parameters for the received username. The username can be obtained by callingSSL_get_srp_username(). SeeSRP_VBASE_init(3)to parse the verifier file created byopenssl-srp(1)orSRP_create_verifier(3)to generate it. The callback should returnSSL_ERROR_NONEto proceed with the server key exchange,SSL3_AL_FATALfor a fatal error or any value < 0 for a retryable error. In the event of aSSL3_AL_FATALthe alert flag given by*alwill be sent back. By default this will beSSL_AD_UNKNOWN_PSK_IDENTITY.SSL_CTX_set_srp_client_pwd_callback()β sets the client password callback on the client. The callback parameters are the SSL connectionsand the extra argumentargset bySSL_CTX_set_srp_cb_arg(). The callback will be called as part of the generation of the client secrets. It should return the client password in text form orNULLto abort the connection. The resulting memory will be freed by the library as part of the callback resolution. This overrides the effect ofSSL_CTX_set_srp_password(). (Yes, they override each other depending on which one you called last. it's giving drama. π)SSL_CTX_set_srp_verify_param_callback()β sets the SRPgNparameter verification callback on the client. This allows the client to perform custom verification when receiving the server SRP proposed parameters. The callback parameters are the SSL connectionsand the extra argumentargset bySSL_CTX_set_srp_cb_arg(). The callback should return a positive value to accept the server parameters. Returning0or a negative value will abort the connection. The server parameters can be obtained by callingSSL_get_srp_N()andSSL_get_srp_g(). Sanity checks are already performed by the library after the handshake (B % Nnon zero, check against the strength parameter) and are not necessary. If no callback is set thegandNparameters will be checked against knownRFC 5054values.
π¦ The SSL_set_srp_server_param* ones
SSL_set_srp_server_param()β sets all SRP parameters for the connections.Nandgare the SRP group parameters,sais the user salt,vthe password verifier andinfois the optional user info. All in one go, one shot, slay. β¨SSL_set_srp_server_param_pw()β sets all SRP parameters for the connectionsby generating a random salt and a password verifier.useris the username,passthe password andgrpthe SRP group parameters identifier forSRP_get_default_gN(3). She does the salt math for you, queen behavior. π
π The SSL_get_srp_* getters
SSL_get_srp_g()β returns the SRP group generator fors, or from the underlyingSSL_CTXif it isNULL.SSL_get_srp_N()β returns the SRP prime fors, or from the underlyingSSL_CTXif it isNULL.SSL_get_srp_username()β returns the SRP username fors, or from the underlyingSSL_CTXif it isNULL.SSL_get_srp_userinfo()β returns the SRP user info fors, or from the underlyingSSL_CTXif it isNULL.
π RETURN VALUES π
- All
SSL_CTX_set_*functions return1on success and0on failure. SSL_set_srp_server_param()returns1on success and-1on failure. (yes, negative one. she's built different.)- The
SSL_get_SRP_*functions return a pointer to the requested data, the memory is owned by the library and should not be freed by the caller. Do NOT free it. Put thefree()down. π
π EXAMPLES π
Setup SRP parameters on the client π
#include <openssl/ssl.h>
const char *username = "username";
const char *password = "password";
SSL_CTX *ctx = SSL_CTX_new(TLS_client_method());
if (!ctx)
/* Error */
if (!SSL_CTX_set_srp_username(ctx, username))
/* Error */
if (!SSL_CTX_set_srp_password(ctx, password))
/* Error */
Setup SRP server with verifier file π§
#include <openssl/srp.h>
#include <openssl/ssl.h>
const char *srpvfile = "password.srpv";
int srpServerCallback(SSL *s, int *ad, void *arg)
{
SRP_VBASE *srpData = (SRP_VBASE*) arg;
char *username = SSL_get_srp_username(s);
SRP_user_pwd *user_pwd = SRP_VBASE_get1_by_user(srpData, username);
if (!user_pwd)
/* Error */
return SSL3_AL_FATAL;
if (SSL_set_srp_server_param(s, user_pwd->N, user_pwd->g,
user_pwd->s, user_pwd->v, user_pwd->info) < 0)
/* Error */
SRP_user_pwd_free(user_pwd);
return SSL_ERROR_NONE;
}
SSL_CTX *ctx = SSL_CTX_new(TLS_server_method());
if (!ctx)
/* Error */
/*
* seedKey should contain a NUL terminated sequence
* of random non NUL bytes
*/
const char *seedKey;
SRP_VBASE *srpData = SRP_VBASE_new(seedKey);
if (SRP_VBASE_init(srpData, (char*) srpvfile) != SRP_NO_ERROR)
/* Error */
SSL_CTX_set_srp_cb_arg(ctx, srpData);
SSL_CTX_set_srp_username_callback(ctx, srpServerCallback);
β SEE ALSO β
ssl(7), openssl-srp(1), SRP_VBASE_new(3), SRP_create_verifier(3)
π HISTORY π
These functions were added in OpenSSL 1.0.1 and deprecated in OpenSSL 3.0. She had a good run, bestie. π―οΈ
π COPYRIGHT π
Copyright 2018-2021 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.
and that's the whole page, no crumbs left π«Ά this was SSL_CTX_SET_SRP_PASSWORD(3SSL) from OpenSSL 4.0.3, dated 2026-09-29. go forth and don't use deprecated functions, mwah πβ¨
π¦ where this page comes from
- ubuntu stonking: libssl-doc 4.0.3-1ubuntu1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms