Skip to content

tls-session-ticket-keys (for DoT) fails in Windows #158

@hdais

Description

@hdais

** Windows only issue **

Unbound fails to read tls-session-ticket-keys files containing byte sequence 0x0d 0x0a (CRLF) or 0x1a (EOF) complaining that size of file is too short (<80 bytes), probably because Unbound fopen()s key files in text mode.

service.conf:

server:
    interface: 0.0.0.0@853
    tls-service-key: privkey.pem
    tls-service-pem: cert.pem
    tls-session-ticket-keys: crlfkey.txt   # 80 bytes file containing 0x0d 0x0a (CRLF) 

Examples of "bad" key files:

unbound.log

C:\Unbound>unbound.exe -c service.conf
[1580490664] unbound.exe[14412:0] error: tls-session-ticket-key crlfkey.txt is 79 bytes, must be 80 bytes
[1580490664] unbound.exe[14412:0] fatal error: could not set session ticket SSL_CTX

Probably because Unbound fopen()s key files in text mode. (Sorry I can't create patch since I don't have development environment for Windows)
listen_sslctx_setup_ticket_keys() in util/net_help.c:

int listen_sslctx_setup_ticket_keys(void* sslctx, struct config_strlist* tls_session_ticket_keys) {
        ...
    for(p = tls_session_ticket_keys; p; p = p->next) {
        ...
        f = fopen(p->str, "r");  /* <===  it should be "rb". */ 
        ...
        n = fread(data, 1, 80, f);
        ...
        if(n != 80) {
            log_err("tls-session-ticket-key %s is %d bytes, must be 80 bytes", p->str, (int)n);
        }
    }

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions