diff --git a/src/interfaces/libpq/fe-secure-openssl.c b/src/interfaces/libpq/fe-secure-openssl.c
index 5bb9d9779d828..ec5d87773df08 100644
--- a/src/interfaces/libpq/fe-secure-openssl.c
+++ b/src/interfaces/libpq/fe-secure-openssl.c
@@ -840,7 +840,11 @@ initialize_SSL(PGconn *conn)
 		 * further overridden by the SSL_CERT_DIR and SSL_CERT_FILE
 		 * environment variables.
 		 */
+#if defined(WIN32) && OPENSSL_VERSION_PREREQ(3, 2)
+		if (SSL_CTX_load_verify_store(SSL_context, "org.openssl.winstore:") != 1)
+#else
 		if (SSL_CTX_set_default_verify_paths(SSL_context) != 1)
+#endif
 		{
 			char	   *err = SSLerrmessage(ERR_get_error());
 
