diff --git a/gio/tests/gtlsconsoleinteraction.c b/gio/tests/gtlsconsoleinteraction.c
index 470e6db..333b17e 100644
--- a/gio/tests/gtlsconsoleinteraction.c
+++ b/gio/tests/gtlsconsoleinteraction.c
@@ -22,6 +22,7 @@
 
 #include "config.h"
 
+#include <stdio.h>
 #include <string.h>
 
 #include "gtlsconsoleinteraction.h"
@@ -34,6 +35,17 @@
 
 G_DEFINE_TYPE (GTlsConsoleInteraction, g_tls_console_interaction, G_TYPE_TLS_INTERACTION);
 
+#ifdef G_OS_WIN32
+/* No getpass() on Windows, just use fgets(). (Note: this causes the password
+ * to be echoed to the screen. Do not do this in real code!) */
+static gchar *
+getpass (const gchar *prompt)
+{
+	gchar *result = g_malloc (128);
+	return fgets (result, 128, stdin);
+}
+#endif
+
 static GTlsInteractionResult
 g_tls_console_interaction_ask_password (GTlsInteraction    *interaction,
                                         GTlsPassword       *password)
