@@ -62,6 +62,14 @@ typedef struct tport_nat_s tport_nat_t;
6262#include <errno.h>
6363#include <limits.h>
6464
65+ #if HAVE_WIN32
66+ #include <io.h>
67+ #define access (_filename , _mode ) _access(_filename, _mode)
68+ #define R_OK (04)
69+ #else
70+ #include <unistd.h>
71+ #endif
72+
6573#ifndef IPPROTO_SCTP
6674#define IPPROTO_SCTP (132)
6775#endif
@@ -71,6 +79,7 @@ typedef struct tport_nat_s tport_nat_t;
7179#include <sofia-sip/rbtree.h>
7280
7381#include "tport_internal.h"
82+ #include "tport_tls.h"
7483
7584#if HAVE_FUNC
7685#elif HAVE_FUNCTION
@@ -280,6 +289,45 @@ int tport_is_verified(tport_t const *self)
280289 return tport_has_tls (self ) && self -> tp_is_connected && self -> tp_verified ;
281290}
282291
292+ /** Reload TLS certificates on all TLS primary transports. */
293+ int tport_reload_tls (tport_t * self , char const * cert_dir )
294+ {
295+ su_home_t autohome [SU_HOME_AUTO_SIZE (1024 )];
296+ tls_issues_t ti = {0 };
297+ tport_t * tp ;
298+ int reloaded = 0 ;
299+
300+ if (!self || !cert_dir )
301+ return -1 ;
302+
303+ su_home_auto (autohome , sizeof autohome );
304+
305+ ti .key = su_sprintf (autohome , "%s/%s" , cert_dir , "agent.pem" );
306+ if (access (ti .key , R_OK ) != 0 )
307+ ti .key = su_sprintf (autohome , "%s/%s" , cert_dir , "tls.pem" );
308+ ti .cert = ti .key ;
309+ ti .CAfile = su_sprintf (autohome , "%s/%s" , cert_dir , "cafile.pem" );
310+ if (access (ti .CAfile , R_OK ) != 0 )
311+ ti .CAfile = su_sprintf (autohome , "%s/%s" , cert_dir , "tls.pem" );
312+ ti .CApath = su_strdup (autohome , cert_dir );
313+ ti .randFile = su_sprintf (autohome , "%s/%s" , cert_dir , "tls_seed.dat" );
314+ ti .configured = 1 ;
315+
316+ for (tp = tport_primaries (self ); tp ; tp = tport_next (tp )) {
317+ if (tport_has_tls (tp )) {
318+ tport_tls_primary_t * tlspri = (tport_tls_primary_t * )tp -> tp_pri ;
319+ if (tlspri -> tlspri_master ) {
320+ if (tls_reload_cert (tlspri -> tlspri_master , & ti ) == 0 )
321+ reloaded ++ ;
322+ }
323+ }
324+ }
325+
326+ su_home_deinit (autohome );
327+
328+ return reloaded ;
329+ }
330+
283331/** Return true if transport is being updated. */
284332int tport_is_updating (tport_t const * self )
285333{
0 commit comments