class CZMQ::FFI::Zcert

work with CURVE security certificates @note This class is 100% generated using zproject.

Public Class Methods

__new()
Alias for: new
create_finalizer_for(ptr) click to toggle source

@param ptr [::FFI::Pointer] @return [Proc]

# File lib/czmq-ffi-gen/czmq/ffi/zcert.rb, line 35
def self.create_finalizer_for(ptr)
  Proc.new do
    ptr_ptr = ::FFI::MemoryPointer.new :pointer
    ptr_ptr.write_pointer ptr
    ::CZMQ::FFI.zcert_destroy ptr_ptr
  end
end
load(filename) click to toggle source

Load certificate from file @param filename [String, to_s, nil] @return [CZMQ::Zcert]

# File lib/czmq-ffi-gen/czmq/ffi/zcert.rb, line 104
def self.load(filename)
  ptr = ::CZMQ::FFI.zcert_load(filename)
  __new ptr
end
new(ptr, finalize = true) click to toggle source

Attaches the pointer ptr to this instance and defines a finalizer for it if necessary. @param ptr [::FFI::Pointer] @param finalize [Boolean]

# File lib/czmq-ffi-gen/czmq/ffi/zcert.rb, line 24
def initialize(ptr, finalize = true)
  @ptr = ptr
  if @ptr.null?
    @ptr = nil # Remove null pointers so we don't have to test for them.
  elsif finalize
    @finalizer = self.class.create_finalizer_for @ptr
    ObjectSpace.define_finalizer self, @finalizer
  end
end
new() click to toggle source

Create and initialize a new certificate in memory @return [CZMQ::Zcert]

# File lib/czmq-ffi-gen/czmq/ffi/zcert.rb, line 78
def self.new()
  ptr = ::CZMQ::FFI.zcert_new()
  __new ptr
end
Also aliased as: __new
new_from(public_key, secret_key) click to toggle source

Accepts public/secret key pair from caller @param public_key [::FFI::Pointer, to_ptr] @param secret_key [::FFI::Pointer, to_ptr] @return [CZMQ::Zcert]

# File lib/czmq-ffi-gen/czmq/ffi/zcert.rb, line 87
def self.new_from(public_key, secret_key)
  ptr = ::CZMQ::FFI.zcert_new_from(public_key, secret_key)
  __new ptr
end
new_from_txt(public_txt, secret_txt) click to toggle source

Accepts public/secret key text pair from caller @param public_txt [String, to_s, nil] @param secret_txt [String, to_s, nil] @return [CZMQ::Zcert]

# File lib/czmq-ffi-gen/czmq/ffi/zcert.rb, line 96
def self.new_from_txt(public_txt, secret_txt)
  ptr = ::CZMQ::FFI.zcert_new_from_txt(public_txt, secret_txt)
  __new ptr
end
test(verbose) click to toggle source

Self test of this class

@param verbose [Boolean] @return [void]

# File lib/czmq-ffi-gen/czmq/ffi/zcert.rb, line 292
def self.test(verbose)
  verbose = !(0==verbose||!verbose) # boolean
  result = ::CZMQ::FFI.zcert_test(verbose)
  result
end

Public Instance Methods

__ptr() click to toggle source

Return internal pointer @return [::FFI::Pointer]

# File lib/czmq-ffi-gen/czmq/ffi/zcert.rb, line 48
def __ptr
  raise DestroyedError unless @ptr
  @ptr
end
Also aliased as: to_ptr
__ptr_give_ref() click to toggle source

Nullify internal pointer and return pointer pointer. @note This detaches the current instance from the native object

and thus makes it unusable.

@return [::FFI::MemoryPointer] the pointer pointing to a pointer

pointing to the native object
# File lib/czmq-ffi-gen/czmq/ffi/zcert.rb, line 59
def __ptr_give_ref
  raise DestroyedError unless @ptr
  ptr_ptr = ::FFI::MemoryPointer.new :pointer
  ptr_ptr.write_pointer @ptr
  __undef_finalizer if @finalizer
  @ptr = nil
  ptr_ptr
end
__undef_finalizer() click to toggle source

Undefines the finalizer for this object. @note Only use this if you need to and can guarantee that the native

object will be freed by other means.

@return [void]

# File lib/czmq-ffi-gen/czmq/ffi/zcert.rb, line 71
def __undef_finalizer
  ObjectSpace.undefine_finalizer self
  @finalizer = nil
end
apply(socket) click to toggle source

Apply certificate to socket, i.e. use for CURVE security on socket. If certificate was loaded from public file, the secret key will be undefined, and this certificate will not work successfully.

@param socket [::FFI::Pointer, to_ptr] @return [void]

# File lib/czmq-ffi-gen/czmq/ffi/zcert.rb, line 247
def apply(socket)
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zcert_apply(self_p, socket)
  result
end
destroy() click to toggle source

Destroy a certificate in memory

@return [void]

# File lib/czmq-ffi-gen/czmq/ffi/zcert.rb, line 112
def destroy()
  return unless @ptr
  self_p = __ptr_give_ref
  result = ::CZMQ::FFI.zcert_destroy(self_p)
  result
end
dup() click to toggle source

Return copy of certificate; if certificate is NULL or we exhausted heap memory, returns NULL.

@return [Zcert]

# File lib/czmq-ffi-gen/czmq/ffi/zcert.rb, line 258
def dup()
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zcert_dup(self_p)
  result = Zcert.__new result, true
  result
end
eq(compare) click to toggle source

Return true if two certificates have the same keys

@param compare [Zcert, #__ptr] @return [Boolean]

# File lib/czmq-ffi-gen/czmq/ffi/zcert.rb, line 270
def eq(compare)
  raise DestroyedError unless @ptr
  self_p = @ptr
  compare = compare.__ptr if compare
  result = ::CZMQ::FFI.zcert_eq(self_p, compare)
  result
end
meta(name) click to toggle source

Get metadata value from certificate; if the metadata value doesn't exist, returns NULL.

@param name [String, to_s, nil] @return [String]

# File lib/czmq-ffi-gen/czmq/ffi/zcert.rb, line 188
def meta(name)
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zcert_meta(self_p, name)
  result
end
meta_keys() click to toggle source

Get list of metadata fields from certificate. Caller is responsible for destroying list. Caller should not modify the values of list items.

@return [Zlist]

# File lib/czmq-ffi-gen/czmq/ffi/zcert.rb, line 199
def meta_keys()
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zcert_meta_keys(self_p)
  result = Zlist.__new result, false
  result
end
null?() click to toggle source

@return [Boolean]

# File lib/czmq-ffi-gen/czmq/ffi/zcert.rb, line 43
def null?
  !@ptr or @ptr.null?
end
print() click to toggle source

Print certificate contents to stdout

@return [void]

public_key() click to toggle source

Return public part of key pair as 32-byte binary string

@return [::FFI::Pointer]

# File lib/czmq-ffi-gen/czmq/ffi/zcert.rb, line 122
def public_key()
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zcert_public_key(self_p)
  result
end
public_txt() click to toggle source

Return public part of key pair as Z85 armored string

@return [String]

# File lib/czmq-ffi-gen/czmq/ffi/zcert.rb, line 142
def public_txt()
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zcert_public_txt(self_p)
  result
end
save(filename) click to toggle source

Save full certificate (public + secret) to file for persistent storage This creates one public file and one secret file (filename + “_secret”).

@param filename [String, to_s, nil] @return [Integer]

# File lib/czmq-ffi-gen/czmq/ffi/zcert.rb, line 212
def save(filename)
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zcert_save(self_p, filename)
  result
end
save_public(filename) click to toggle source

Save public certificate only to file for persistent storage

@param filename [String, to_s, nil] @return [Integer]

# File lib/czmq-ffi-gen/czmq/ffi/zcert.rb, line 223
def save_public(filename)
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zcert_save_public(self_p, filename)
  result
end
save_secret(filename) click to toggle source

Save secret certificate only to file for persistent storage

@param filename [String, to_s, nil] @return [Integer]

# File lib/czmq-ffi-gen/czmq/ffi/zcert.rb, line 234
def save_secret(filename)
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zcert_save_secret(self_p, filename)
  result
end
secret_key() click to toggle source

Return secret part of key pair as 32-byte binary string

@return [::FFI::Pointer]

# File lib/czmq-ffi-gen/czmq/ffi/zcert.rb, line 132
def secret_key()
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zcert_secret_key(self_p)
  result
end
secret_txt() click to toggle source

Return secret part of key pair as Z85 armored string

@return [String]

# File lib/czmq-ffi-gen/czmq/ffi/zcert.rb, line 152
def secret_txt()
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zcert_secret_txt(self_p)
  result
end
set_meta(name, format, *args) click to toggle source

Set certificate metadata from formatted string.

@param name [String, to_s, nil] @param format [String, to_s, nil] @param args [Array<Object>] see github.com/ffi/ffi/wiki/examples#using-varargs @return [void]

# File lib/czmq-ffi-gen/czmq/ffi/zcert.rb, line 165
def set_meta(name, format, *args)
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zcert_set_meta(self_p, name, format, *args)
  result
end
to_ptr()

So external Libraries can just pass the Object to a FFI function which expects a :pointer

Alias for: __ptr
unset_meta(name) click to toggle source

Unset certificate metadata.

@param name [String, to_s, nil] @return [void]

# File lib/czmq-ffi-gen/czmq/ffi/zcert.rb, line 176
def unset_meta(name)
  raise DestroyedError unless @ptr
  self_p = @ptr
  result = ::CZMQ::FFI.zcert_unset_meta(self_p, name)
  result
end