Exemplo n.º 1
0
 def save(self, master_key: PKey):
     with io.StringIO() as buffer_:
         master_key.write_private_key(buffer_)
         pem = buffer_.getvalue()
     self.driver.upload_object_via_stream(
         self._countable_iterator([pem]), self.container, self.object_name,
         {'content_type': 'application/x-pem-key'})
Exemplo n.º 2
0
 def save(self, master_key: PKey):
     with io.StringIO() as buffer_:
         master_key.write_private_key(buffer_)
         pem = buffer_.getvalue()
     self.driver.upload_object_via_stream(
         self._countable_iterator([pem]), self.container, self.object_name, {"content_type": "application/x-pem-key"}
     )
Exemplo n.º 3
0
 def save(self, master_key: PKey):
     extra = {'content_type': 'application/x-pem-key'}
     if isinstance(self.driver, S3StorageDriver):
         # On some cases (altough unknown condition), S3 driver failed to
         # match signature when it uploads object through stream.
         # This is workaround to upload the master key without stream.
         with tempfile.NamedTemporaryFile('w+', encoding='utf-8') as f:
             master_key.write_private_key(f)
             f.file.flush()
             self.driver.upload_object(f.name, self.container,
                                       self.object_name, extra)
         return
     with io.StringIO() as buffer_:
         master_key.write_private_key(buffer_)
         pem = buffer_.getvalue()
     self.driver.upload_object_via_stream(self._countable_iterator([pem]),
                                          self.container, self.object_name,
                                          extra)
Exemplo n.º 4
0
 def save(self, master_key: PKey) -> None:
     extra = {'content_type': 'application/x-pem-key'}
     if isinstance(self.driver, S3StorageDriver):
         # On some cases (altough unknown condition), S3 driver failed to
         # match signature when it uploads object through stream.
         # This is workaround to upload the master key without stream.
         with tempfile.NamedTemporaryFile('w+', encoding='utf-8') as f:
             master_key.write_private_key(f)
             getattr(f, 'file').flush()  # workaround mypy
             self.driver.upload_object(
                 f.name, self.container, self.object_name, extra
             )
         return
     with io.StringIO() as buffer_:
         master_key.write_private_key(buffer_)
         pem = getattr(buffer_, 'getvalue')()  # workaround mypy
     self.driver.upload_object_via_stream(
         type(self)._countable_iterator([pem]),
         self.container,
         self.object_name,
         extra
     )