Commit Graph

831 Commits

Author SHA1 Message Date
Peter Hamilton 487dfc78ab Update the DeriveKey payloads
This change makes minor updates to the DeriveKey payloads, fixing
error messages, comments, and local variable names to comply with
the current payload format. The corresponding unit test suite has
been updated to reflect these changes.

This change prepares the DeriveKey payloads for future updates to
support KMIP 2.0.
2019-03-21 16:11:52 -04:00
Peter Hamilton e2f93d49d7 Move the KMIPProtocol from server to services
This change moves the KMIPProtocol class from the server module
to the services module. Because the client uses KMIPProtocol, and
KMIPProtocol lived in the server module, the client would end up
importing server libraries whenever it was used. If there are any
issues with server dependencies, this would cause the client to
fail for no good reason. This change now insulates the client from
the server code base and prevents this case from happening.

See #509
2019-03-21 10:43:55 -04:00
Peter Hamilton 6f81d79c53 Update the CreateKeyPair payloads to support KMIP 2.0
This change updates the CreateKeyPair payloads to support KMIP 2.0
features, including swapping out TemplateAttributes for the new
Attributes structure in the request payload and removing all
attribute-related encodings from the response payload. Unit tests
have been added to cover these changes.
2019-03-18 14:38:24 -04:00
Peter Hamilton 1c85295d89 Update utilities to remove use of TemplateAttribute subclasses
This change updates the TemplateAttribute conversion utilities to
remove use of various TemplateAttribute subclasses. This reflects
the usage updates added for CreateKeyPair support. All related
unit tests have been updated to reflect this change.
2019-03-18 13:39:30 -04:00
Peter Hamilton 71d508019a Update the CreateKeyPair payloads
This change updates the CreateKeyPair payloads to the current
payload format, adding properties for different payload attributes
and adding comparison and string operators. Changes are also made
to the PyKMIP clients and the surrounding testing infrastructure
to reflect the payload changes. The official unit test suite for
the CreateKeyPair payloads has been updated to also reflect these
changes.

This change prepares the CreateKeyPair payloads for future
updates to support KMIP 2.0.
2019-03-15 16:51:07 -04:00
Peter Hamilton fe3095c22b Update the Locate payloads to support KMIP 2.0
This change updates the Locate payloads to support KMIP 2.0
features, including swapping out individual Attribute structures
for the new Attributes structure in the request payload. Unit
tests have been added to cover these changes.
2019-03-12 10:01:18 -04:00
Peter Hamilton 938a0a3b16 Update the Locate payloads
This change updates the Locate payloads to the current payload
format, adding properties for different payload attributes and
adding comparison and string operators. Changes are also made to
the PyKMIP clients and the surrounding testing infrastructure to
reflect the payload changes. An official unit test suite for the
Locate payloads has also been included, which will eventually
replace the existing Locate message tests elsewhere in the test
suite.

This change prepares the Locate payloads for future updates to
support KMIP 2.0.
2019-03-12 08:34:35 -04:00
Peter Hamilton 438ec42574 Add bit mask enumeration utilities
This changes adds several utilities for working with bit mask
enumerations, including functions to compute bit masks from lists
of enumeration values and vice versa. Unit tests have been added
to cover these new utilities.
2019-03-07 17:20:32 -05:00
Peter Hamilton 8e7dae6629 Update the Register payloads to support KMIP 2.0
This change updates the Register payloads to support KMIP 2.0
features, including swapping out TemplateAttributes for the new
Attributes structure in the request payload and removing all
attribute-related encodings from the response payload. Unit tests
have been added to cover these changes.
2019-03-06 15:29:51 -05:00
Peter Hamilton a81233aa2a Update the Register payloads
This change updates the Register payloads to the current payload
format, adding properties for different payload attributes and
adding comparison and string operators. Changes are also made to
the PyKMIP clients and the surrounding testing infrastructure to
reflect the payload changes. An official unit test suite for the
Register payloads has also been included, which will eventually
replace the existing Register message tests elsewhere in the test
suite.

This change prepares the Register payloads for future updates to
support KMIP 2.0.
2019-03-06 13:37:39 -05:00
Andrey Smirnov 1a723f224d Move TLS server handshake down to connection thread
When TLS handshake is performed while in `accept()` call, main thread
might blocked up to network timeout effectively locking out other
clients from being able to establish connection with PyKMIP server.

Easy way to reproduce the problem:

1. Start PyKMIP server

2. Establish TCP connection with `nc -v 127.0.0.1 5696`

3. Attempt to connect (concurrently):
   `openssl s_client -host 127.0.0.1 -port 5696`

Without the fix, `openssl` would be blocked (won't even do initial TLS
handshake) until `nc` connection times out.
2019-03-04 14:58:11 -05:00
Peter Hamilton 004ff92ffb Update the Create payloads to support KMIP 2.0
This change updates the Create payloads to support KMIP 2.0
features, including swapping out TemplateAttributes for the new
Attributes structure in the request payload and removing all
attribute-related encodings from the response payload. Unit tests
have been added to cover these changes.
2019-03-01 10:19:25 -05:00
Peter Hamilton b8ca94b518 Add utilities for converting TemplateAttributes and Attributes
This change adds several attribute-related utilities that support
converting TemplateAttribute structures to the new Attributes
structure and back. These utilities will be used in the updated
operation payloads to support seamless KMIP 2.0 encodings without
requiring broad payload internal and external usage changes.

Unit tests have been included to cover the new utility functions.
2019-03-01 08:32:54 -05:00
Peter Hamilton 30d7773d96 Update the Create payloads
This change updates the Create payloads to the current payload
format, adding properties for different payload attributes and
adding comparison and string operators. Changes are also made to
the PyKMIP clients and the surrounding testing infrastructure to
reflect the payload changes. An official unit test suite for the
Create payloads has also been included, which will eventually
replace the existing Create message tests elsewhere in the test
suite.

This change prepares the Create payloads for future updates to
support KMIP 2.0.
2019-02-27 16:40:22 -05:00
Andrey Smirnov a58a3a3bea Provision CA extension in CA cert
Without that, on modern OpenSSL libs this gives an error:

```
verify error:num=24:invalid CA certificate
```
2019-02-27 08:53:46 -05:00
Peter Hamilton 54f3688a14 Block Attributes encoding and decoding on non KMIP 2.0 calls
This change adds a check to the read and write methods of the new
Attributes object that raises a new VersionNotSupported exception
if KMIP 2.0 is not the version used for encoding and decoding.
The Attributes object is not defined for older versions of KMIP
and therefore cannot be correctly encoded or decoded in those use
cases.
2019-02-26 08:29:26 -05:00
Peter Hamilton 24f30d46b2 Add OrderedEnum to enable enum value comparisons
This change adds a new Enum subclass, OrderedEnum, that provides
comparison operators allowing for comparisons between enum values.
This will be used going forward with the KMIPVersion enum enabling
version checking on supported or unsupported object types.
2019-02-25 12:50:43 -05:00
Peter Hamilton 2057a48b31 Add KMIP version markers to enumerations 2019-02-22 12:03:43 -05:00
Peter Hamilton bc3e81b577 Add KMIP 2.0-style attribute handling
This change adds a new Attributes object to the object hierarchy,
which replaces TemplateAttributes in KMIP 2.0. The old attribute
components, like the AttributeName and AttributeIndex, are no
longer used and are instead replaced with the KMIP TTLV tag for
the attributes in question. This brings the attribute encoding
process in line with the rest of the KMIP specification.

To support this change, additional attribute and enumeration
utility functions have been added to simply attribute building
and attribute/enumeration validity checking. New test cases
covering this new functionality are also included.
2019-02-22 09:59:05 -05:00
Peter Hamilton e986488ebe Add KMIP 2.0 enumerations 2019-02-15 07:36:53 -05:00
Peter Hamilton dcade2a264 Update object hierarchy read/write to support the KMIP version
This change updates the PyKMIP object hierarchy's read/write
method signatures to support propagation of the KMIP version. The
introduction of KMIP 2.0 introduces future KMIP message encodings
that break backwards compatibility; to support this, PyKMIP must
know what KMIP version is being used when encoding or decoding an
object; the KMIP version residing in the client or server alone
is now insufficient. Prior versions of KMIP, namely 1.0 - 1.4,
have been backwards compatible, obviating the need for the KMIP
version at encode/decode time. Going forward, this is no longer
true.

The PyKMIP client and server have been updated to include the
KMIP version when making calls to read/write, as have the
associated test cases covering this functionality.
2019-02-06 17:06:47 -05:00
Peter Hamilton c012a430aa Fix flake8 warnings to reflect modern Python style 2019-02-01 11:53:18 -05:00
Peter Hamilton 7648ea801b Add additional session error logging for authentication failures 2019-01-29 19:18:05 -05:00
Peter Hamilton 5e212b32a3 Update the Travis CI config to output log files on test failures
This change updates the Travis CI configuration file to output the
contents of the PyKMIP server and SLUGS log files if:

* a test failure occurred, and
* the log files exist in the test environment

This makes debugging server and service failures much easier in
Travis CI, specifically during integration and functional test
suite runs.
2019-01-29 14:22:19 -05:00
Peter Hamilton f75a74922a Migrate from using assertRaisesRegexp to assertRaisesRegex 2019-01-28 10:38:05 -05:00
Peter Hamilton 4828e0d845 Fix AttributeError in client Rekey results with missing payloads
This change fixes a bug in the KMIPProxy client's support for the
Rekey operation. Specifically, if the operation fails and does not
return a payload, the client will still try to reference the
payload object when checking for TemplateAttribute data. This
causes an AttributeError since the payload is None. This change
fixes this and adds a unit test that covers this specific case.

Fixes #474
2018-12-07 08:58:36 -05:00
Peter Hamilton 8fd7eb5ab6 Clean up test requirements and remove unused dependencies 2018-12-05 15:55:40 -05:00
Peter Hamilton c5e4c4a290 Update the PyKMIP clients to support changing their KMIP version
This change updates the PyKMIP clients, adding support for getting
and setting the KMIP version they use when making KMIP requests.
You can now do:

>>> client.kmip_version

to get the KMIP version enumeration the client is using. Use:

>>> client.kmip_version = enums.KMIPVersion.KMIP_1_1

to set the KMIP version the client uses.

The client unit tests have been updated to check and cover these
changes.

Fixes #470
2018-12-04 15:01:24 -05:00
Peter Hamilton 40c064a290 Update the server to nominally support KMIP 1.3 and 1.4
This change updates the list of KMIP versions supported by the
server. While the server does not support any specific KMIP 1.3
or 1.4 features, the protocol formats are compatible across KMIP
1.0 to 1.4. Without this change, KMIP 1.3 and 1.4 requests for
older operations, like Create, Get, and Destroy, would fail.

This change also updates the server unit tests impacted by this
change.

Closes #451
2018-12-04 12:42:00 -05:00
Peter Hamilton 1a5c2ff490
Merge pull request #467 from OpenKMIP/feat/fix-pending-deprecations
Fix pending deprecation warnings caused by dependency upgrades
2018-11-16 12:32:04 -05:00
Peter Hamilton 9a5db6d5e1 Fix pending deprecation warnings caused by dependency upgrades
This change fixes various pending deprecation warnings throughout
the library caused by recent updates to different dependencies.
While PyKMIP no longer directly triggers these warnings, some
dependencies still do when run through the test suite.
2018-11-16 11:42:05 -05:00
Peter Hamilton 257fcca477
Merge pull request #466 from OpenKMIP/feat/add-python37-support
Add support for Python 3.7
2018-11-16 08:34:22 -05:00
Peter Hamilton 3e48bab13e Add support for Python 3.7
This change adds official library support for Python 3.7, including
updating the testing infrastructure for both tox and Travis CI and
updating the library package metadata in setup.py.
2018-11-15 16:28:29 -05:00
Peter Hamilton 6d58bc4093
Merge pull request #465 from OpenKMIP/tests/add-xenial-platform-testing
Add Ubuntu 16.04 LTS as a target test platform for Travis CI
2018-11-15 15:42:13 -05:00
Peter Hamilton c74d61a971 Add Ubuntu 16.04 LTS as a target test platform for Travis CI
This change adds Ubuntu 16.04 LTS (Xenial Xerus) as a target test
platform in the Travis CI configuration file. New test builds for
all unit, integration, functional, style, security, and doc checks
should now be built for Xenial during continuous integration runs.
2018-11-15 14:37:21 -05:00
Peter Hamilton cb776ac59f
Merge pull request #463 from OpenKMIP/bug/fix-invalid-escape-sequences
Remove invalid escape sequences
2018-11-15 14:30:49 -05:00
Peter Hamilton 8abe3de8cb Remove invalid escape sequences
A recent style update to Python 3.6 adds deprecation W605, which
tightens the usage of invalid escape sequences. This patch removes
any instances of invalid escape sequences from the PyKMIP code
base, bringing the library back up to compliance with Python style.
2018-11-15 13:53:06 -05:00
Peter Hamilton 0819574424
Merge pull request #458 from tipabu/eoferror-text
Change EOFError text
2018-10-10 08:51:40 -04:00
Peter Hamilton 1365047dcb
Merge pull request #457 from tipabu/secure-logging
Secure logging by default
2018-10-10 08:51:07 -04:00
Tim Burke f60bae83d0 Secure logging by default
As an application developer, you might expect to be able to turn on
debug logging at the root logger with something like

    logging.basicConfig(level=logging.DEBUG)

However, if the application needed to fetch any secrets from a KMIP
server, these previously would be logged as part of the wire protocol.
Further, any passwords in configs would also get logged at DEBUG.
Applications would need to proactively silence such logging, as in
https://github.com/openstack/swift/commit/12b6d46

Now, we will default the logger level to INFO to suppress the debug
logging. However, seeing the on-wire data may still be useful, for
example when developing a new KMIP server. So, allow developers to
consciously set the logger level to DEBUG.
2018-10-09 14:24:22 -07:00
Tim Burke 8e82438f25 Change EOFError text
The old text made perfect sense when in a server context, trying to
read requests from clients, but KMIPProtocol is also used by *clients*
to read *responses*. Let's change it to something a little more
request/response agnostic.
2018-10-09 14:05:55 -07:00
Peter Hamilton 9fc9c62887
Merge pull request #447 from tipabu/bug-381
Clean up KMIPProxy initialization and destruction
2018-06-28 11:24:45 -04:00
Peter Hamilton a931850c51
Merge pull request #446 from tipabu/improved-errors-and-logging
Improve errors and logging
2018-06-28 11:23:11 -04:00
Tim Burke d291c50bd6 Clean up KMIPProxy initialization and destruction
Fixes #381.
2018-06-22 12:26:48 -07:00
Tim Burke 8bf7592db9 Preserve the stack when re-raising connection errors 2018-06-22 12:11:16 -07:00
Tim Burke 6306846b45 Log connection error details per-host
Otherwise, you don't get much insight into why you had to settle for
your third configured host. Now, you can get information like

   An error occurred while connecting to appliance foo.bar:
      [Errno -5] No address associated with hostname
   An error occurred while connecting to appliance localhost:
      [Errno 111] Connection refused

even when we ultimately succeed in creating a client.
2018-06-22 12:11:16 -07:00
Tim Burke eb2fee80e8 Stop logging tracebacks when we're about to reraise
At that point, it's up to the caller to decide whether a stack trace is
appropriate; if the caller decides the connection error is recoverable,
us logging a traceback will only confuse things.

Also, prevent a TypeError during log interpolation by actually using the
argument we were providing.
2018-06-22 11:53:25 -07:00
Tim Burke 3d2a7edc94 Have ProxyKmipClient use a non-root logger 2018-06-22 11:07:50 -07:00
Peter Hamilton 4e138207af
Merge pull request #443 from tipabu/reraise
Reraise exceptions to preserve stack traces
2018-06-19 14:32:32 -04:00
Tim Burke 5ffb5d74f6 Reraise exceptions to preserve stack traces
Otherwise, you can hit errors with tracebacks like

   Traceback (most recent call last):
     ...
     File ".../kmip/pie/client.py", line 1573, in __enter__
       self.open()
     File ".../kmip/pie/client.py", line 135, in open
       raise e
   IOError: [Errno 2] No such file or directory

... which isn't terribly useful; it doesn't give you any information
about *what* file wasn't found. By using a bare `raise`, you preserve
the rest of the stack and get

   Traceback (most recent call last):
     ...
     File ".../kmip/pie/client.py", line 1573, in __enter__
       self.open()
     File ".../kmip/pie/client.py", line 131, in open
       self.proxy.open()
     File ".../kmip/services/kmip_client.py", line 221, in open
       self._create_socket(sock)
     File ".../kmip/services/kmip_client.py", line 246, in _create_socket
       suppress_ragged_eofs=self.suppress_ragged_eofs)
     File ".../eventlet/green/ssl.py", line 379, in wrap_socket
       return GreenSSLSocket(sock, *a, **kw)
     File ".../eventlet/green/ssl.py", line 68, in __init__
       ca_certs, do_handshake_on_connect and six.PY2, *args, **kw)
     File ".../ssl.py", line 558, in __init__
       self._context.load_verify_locations(ca_certs)
   IOError: [Errno 2] No such file or directory

... which makes it clear that it was a problem with the CA certificate
bundle.
2018-06-19 10:40:56 -07:00