66
77-define (POOL_SUPERVISOR , epp_pool_supervisor ).
88
9+ -define (THIRTY_MINUTES_IN_MS , 30 * 30 * 1000 ).
10+
911-define (WORKER , epp_tls_worker ).
1012
1113% % gen_server callbacks
1214-export ([handle_call /3 , handle_cast /2 , init /1 ,
13- start_link /1 ]).
15+ start_link /1 , terminate / 2 , handle_info / 2 ]).
1416
1517-export ([crl_file /0 ]).
1618
17- -record (state , {socket , port , options }).
19+ -record (state , {socket , port , options , timer }).
1820
1921start_link (Port ) ->
2022 gen_server :start_link ({local , ? SERVER }, ? MODULE , Port ,
@@ -27,11 +29,13 @@ init(Port) ->
2729 {cacertfile , ca_cert_file ()}, {certfile , cert_file ()},
2830 {keyfile , key_file ()}],
2931 Options = handle_crl_check_options (DefaultOptions ),
32+ {ok , TimerReference } =
33+ timer :send_interval (? THIRTY_MINUTES_IN_MS , reload_clr_file ),
3034 {ok , ListenSocket } = ssl :listen (Port , Options ),
3135 gen_server :cast (self (), accept ),
3236 {ok ,
3337 # state {socket = ListenSocket , port = Port ,
34- options = Options }}.
38+ options = Options , timer = TimerReference }}.
3539
3640% % Acceptor has only one state that goes in a loop:
3741% % 1. Listen for a connection from anyone.
@@ -52,6 +56,19 @@ handle_cast(accept,
5256 State # state {socket = ListenSocket , port = Port ,
5357 options = Options }}.
5458
59+ handle_info (reload_crl_file , State ) ->
60+ case crl_file () of
61+ undefined -> {noreply , State };
62+ {ok , File } ->
63+ ssl_crl_cache :insert ({file , File }),
64+ {noreply , State }
65+ end .
66+
67+ terminate (_Reason , State ) ->
68+ Timer = State # state .timer ,
69+ timer :cancel (Timer ),
70+ ok .
71+
5572handle_call (_E , _From , State ) -> {noreply , State }.
5673
5774% % Create a worker process. These are short lived and should not be restarted,
0 commit comments