MCPcopy Create free account
hub / github.com/SIPp/sipp / write_keylog_line

Function write_keylog_line

src/sslsocket.cpp:120–141  ·  view source on GitHub ↗

Add a LF to the keylog line and return the number of bytes written or 0 if * writing fails. * see: https://www.ietf.org/archive/id/draft-thomson-tls-keylogfile-00.html https://github.com/tlswg/sslkeylogfile */

Source from the content-addressed store, hash-verified

118 https://github.com/tlswg/sslkeylogfile
119*/
120static int write_keylog_line(const char* filename, const char *line)
121{
122 FILE *keylog_fp = nullptr;
123 char buf[256]; /* current keylog maximum line length is 195 */
124 size_t line_len = strlen(line);
125
126 if(line_len == 0 || line_len > sizeof(buf) - 2) {
127 /* Empty line or too big to fit in a LF and NULL. */
128 return 0;
129 }
130 keylog_fp = fopen(filename, "a");
131 if (keylog_fp) {
132 memcpy(buf, line, line_len);
133 if(line[line_len - 1] != '\n') {
134 buf[line_len++] = '\n';
135 }
136 buf[line_len] = '\0';
137 fputs(buf, keylog_fp);
138 fclose(keylog_fp);
139 }
140 return line_len-1;
141}
142
143static void sip_tls_keylog_callback(const SSL *ssl, const char *line)
144{

Callers 1

sip_tls_keylog_callbackFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected