os.write() needs bytes objects on python3 while python2 can work with either a byte or unicode string. Mark the DUMMY_CA_CERT string as a byte string so it will work. Fixes #19265 Fixes #19266