Module: Puppet::X509::PemStore Private
- Included in:
- CertProvider
- Defined in:
- lib/puppet/x509/pem_store.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Methods for managing PEM encoded files. While PEM encoded strings are always ASCII, the files may contain user specified comments, so they are UTF-8 encoded.
Instance Method Summary collapse
-
#delete_pem(path) ⇒ Boolean
private
Delete a pem encoded object, if it exists.
-
#load_pem(path) ⇒ String?
private
Load a pem encoded object.
-
#save_pem(pem, path, owner: nil, group: nil, mode: 0o644) ⇒ Object
private
Save pem encoded content to a file.
Instance Method Details
#delete_pem(path) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Delete a pem encoded object, if it exists.
51 52 53 54 55 56 |
# File 'lib/puppet/x509/pem_store.rb', line 51 def delete_pem(path) Puppet::FileSystem.unlink(path) true rescue Errno::ENOENT false end |
#load_pem(path) ⇒ String?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Load a pem encoded object.
18 19 20 21 22 |
# File 'lib/puppet/x509/pem_store.rb', line 18 def load_pem(path) Puppet::FileSystem.read(path, encoding: 'UTF-8') rescue Errno::ENOENT nil end |
#save_pem(pem, path, owner: nil, group: nil, mode: 0o644) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Save pem encoded content to a file. If the file doesn’t exist, it will be created. Otherwise, the file will be overwritten. In both cases the contents will be overwritten atomically so other processes don’t see a partially written file.
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/puppet/x509/pem_store.rb', line 34 def save_pem(pem, path, owner: nil, group: nil, mode: 0o644) Puppet::FileSystem.replace_file(path, mode) do |f| f.set_encoding('UTF-8') f.write(pem.encode('UTF-8')) end if !Puppet::Util::Platform.windows? && Puppet.features.root? && (owner || group) FileUtils.chown(owner, group, path) end end |