--- a/lib/dns/openssl_link.c	2019-04-17 06:00:00.086000000 -0400
+++ b/lib/dns/openssl_link_1.c	2019-04-17 06:03:38.556000000 -0400
@@ -385,7 +385,7 @@ dst__openssl_destroy(void) {
 static isc_result_t
 toresult(isc_result_t fallback) {
 	isc_result_t result = fallback;
-	unsigned long err = ERR_get_error();
+	unsigned long err = ERR_peek_error();
 #if defined(HAVE_OPENSSL_ECDSA) && \
     defined(ECDSA_R_RANDOM_NUMBER_GENERATION_FAILED)
 	int lib = ERR_GET_LIB(err);
