diff --git a/src/mod_sso/test/httpd_integration_test.py b/src/mod_sso/test/httpd_integration_test.py
index 933165033144b1068dc75e62f66a9010c69b1906..b6ba6b1c7c038548704498d9dd95445250e137f9 100755
--- a/src/mod_sso/test/httpd_integration_test.py
+++ b/src/mod_sso/test/httpd_integration_test.py
@@ -30,7 +30,7 @@ devnull = open(os.devnull)
 
 
 def _start_httpd(public_key, config_file):
-    with open('public.key', 'w') as fd:
+    with open('public.key', 'wb') as fd:
         fd.write(public_key)
     env = dict(os.environ)
     env['TESTROOT'] = os.getcwd()