You derive it based on the TLS version. SSL_export_keying_material() is fine to use as all OpenSSL versions that implement TLS 1.2 support this. Falling back where it is not available is therefore fine.