Fix plugins.common.Dvsni._setup_challenge_cert.

This commit is contained in:
Jakub Warmuz 2015-10-04 20:13:00 +00:00
parent ed70c948aa
commit 94c6e307c9
No known key found for this signature in database
GPG key ID: 2A7BAD3A489B52EA
2 changed files with 14 additions and 4 deletions

View file

@ -5,6 +5,7 @@ import re
import shutil
import tempfile
import OpenSSL
import zope.interface
from acme.jose import util as jose_util
@ -181,7 +182,11 @@ class Dvsni(object):
self.configurator.reverter.register_file_creation(True, key_path)
self.configurator.reverter.register_file_creation(True, cert_path)
response, cert_pem, key_pem = achall.gen_cert_and_response(s)
response, cert, key = achall.gen_cert_and_response(s)
cert_pem = OpenSSL.crypto.dump_certificate(
OpenSSL.crypto.FILETYPE_PEM, cert)
key_pem = OpenSSL.crypto.dump_privatekey(
OpenSSL.crypto.FILETYPE_PEM, key)
# Write out challenge cert and key
with open(cert_path, "wb") as cert_chall_fd:

View file

@ -2,6 +2,7 @@
import unittest
import mock
import OpenSSL
from acme import challenges
from acme import jose
@ -144,7 +145,9 @@ class DvsniTest(unittest.TestCase):
response = challenges.DVSNIResponse(validation=mock.Mock())
achall = mock.MagicMock()
achall.gen_cert_and_response.return_value = (response, "cert", "key")
key = test_util.load_pyopenssl_private_key("rsa512_key.pem")
achall.gen_cert_and_response.return_value = (
response, test_util.load_cert("cert.pem"), key)
with mock.patch("letsencrypt.plugins.common.open",
mock_open, create=True):
@ -156,10 +159,12 @@ class DvsniTest(unittest.TestCase):
# pylint: disable=no-member
mock_open.assert_called_once_with(self.sni.get_cert_path(achall), "wb")
mock_open.return_value.write.assert_called_once_with("cert")
mock_open.return_value.write.assert_called_once_with(
test_util.load_vector("cert.pem"))
mock_safe_open.assert_called_once_with(
self.sni.get_key_path(achall), "wb", chmod=0o400)
mock_safe_open.return_value.write.assert_called_once_with("key")
mock_safe_open.return_value.write.assert_called_once_with(
OpenSSL.crypto.dump_privatekey(OpenSSL.crypto.FILETYPE_PEM, key))
if __name__ == "__main__":