Questions tagged with Windows Provisioning

Content language: English

Sort by most recent

Browse through the questions and answers listed below or filter and sort to narrow down your results.

basic-connect gives AWS_ERROR_MQTT_UNEXPECTED_HANGUP & error-code 1049

I fail to run the sample [basic-connect](https://github.com/aws/aws-iot-device-sdk-cpp-v2/tree/main/samples/mqtt/basic_connect). i receive: ``` [ERROR] [2022-10-05T13:09:04Z] [00005b28] [socket] - id=000001C5BE6C1E30 handle=0000000000000214: connect completion triggered with error -1073741252 [ERROR] [2022-10-05T13:09:04Z] [00005b28] [socket] - id=000001C5BE6C1E30 handle=0000000000000214: connection error with code 1049 Connection failed with error libaws-c-mqtt: AWS_ERROR_MQTT_UNEXPECTED_HANGUP, The connection was closed unexpectedly. Connection failed ``` When I run: > basic-connect.exe --client_id "ME" --endpoint "[...]-ats.iot.eu-west-1.amazonaws.com" --cert "[...]/Certificate.crt" --key "[...]/private.key" --verbosity "Info" Full output: ``` [INFO] [2022-10-05T13:09:04Z] [00007020] [pki-utils] - static: loading certificate chain with 3 certificates. Connecting... [INFO] [2022-10-05T13:09:04Z] [00007020] [mqtt-client] - id=000001C5BE6AE5F0: using ping timeout of 3000000000 ns [INFO] [2022-10-05T13:09:04Z] [00007020] [thread] - id=000001C5BE69BFD0: cpu affinity of cpu_id 0 was specified, attempting to honor the value. [INFO] [2022-10-05T13:09:04Z] [00005bd8] [socket] - static: initializing WinSock [INFO] [2022-10-05T13:09:04Z] [00005bd8] [socket] - static: loading WSAID_CONNECTEX function [INFO] [2022-10-05T13:09:04Z] [00005bd8] [socket] - static: loading WSAID_ACCEPTEX function [ERROR] [2022-10-05T13:09:04Z] [00005b28] [socket] - id=000001C5BE6C1E30 handle=0000000000000214: connect completion triggered with error -1073741252 [ERROR] [2022-10-05T13:09:04Z] [00005b28] [socket] - id=000001C5BE6C1E30 handle=0000000000000214: connection error with code 1049 [INFO] [2022-10-05T13:09:04Z] [00005b28] [dns] - id=000001C5BE66C600: recording failure for record 2a01:578:3::22f6:70e6 for [...].eu-west-1.amazonaws.com, moving to bad list Connection failed with error libaws-c-mqtt: AWS_ERROR_MQTT_UNEXPECTED_HANGUP, The connection was closed unexpectedly. [INFO] [2022-10-05T13:09:05Z] [00005b28] [mqtt-client] - id=000001C5BE6AE5F0: sending disconnect message as part of graceful shutdown. Connection failed [...]basic_connect\build\x64-Debug\basic-connect.exe (process 30292) exited with code -1. ``` Why is there an overflow ("-1073741252")? I identified 1049 to be "AWS_IO_SOCKET_NO_ROUTE_TO_HOST", what does that mean? Why is the connection not successful? I am using msbuild & win10.
1
answers
0
votes
53
views
asked 2 months ago

aws command installed with awscli library inside a python venv on Windows invokes a python OUTSIDE the venv

For awscli 1.25.86, installing on a freshly minted Windows EC2 (Windows Server 2022 Dataserver), I did this: 1. selected my home directory (`cd`) 2. installed `pyenv` (e.g., via PowerShell using https://github.com/pyenv-win/pyenv-win#power-shell). This said it didn't succeed but seems to have fully installed pyenv. This is not the bug. I had to select a new PowerShell to see the effect of having installed `pyenv`) 3. told `pyenv` to install python 3.8 (`pyenv install 3.8.10`) 4. selected python 3.8 globally (`pyenv global 3.8.10`) 5. created a virtual environment (`pyenv exec python -m venv myvenv`) 6. entered the venv (`myvenv\scripts\activate`) 7. installed `awscli` (`pip install awscli`) 8. tried to invoke `awscli` (`aws --version`). This gives the message `File association not found for extension .py` which is an ignorable problem followed by an error that is the bug I'm reporting: ``` Traceback (most recent call last): File "C:\Users\Andrea\GitHub\Submit4DN\s4dn_venv\Scripts\aws.cmd", line 50, in <module> import awscli.clidriver ModuleNotFoundError: No module named 'awscli' ``` After studying this problem, I believe I know the source of this problem, and am pretty sure it's in the `awscli` library. The library installs `myvenv\scripts\aws.cmd` which implements the `aws` command inside the virtual environment, but that script sniffs around for a `python` to invoke and finds one _outside_ of the virtual environment. The problem isn't that it tries to get out of the virtual environment, it's just apparently oblivious to the presence of one, and so it isn't picky about which python it finds. it successively seeks `python.cmd`, `python.bat`, and `python.exe` (see line 7 of `myenv\scripts\aws.cmd`) but finds `python.cmd` first, and that is not inside the virtual environment. Had it checked `python.exe` first, it would have found the one in the virtual environment. If you swap the order of `(cmd bat exe)` on line 7 of `aws.cmd` so that it searches `(exe bat cmd)` it will invoke the python within the virtual env and so will find the `awscli` that was just installed within the virtual environment. That's not necessarily the right fix. It still feels fragile. But it seems to me that this proves it's the locus of the problem. Another somewhat workaround is to install `awscli` outside of the virtual environment by doing `deactivate`, then `pip install awscli`, then `myvenv/scripts/activate`, and then finally trying `aws --version` and it will work _except_ that if you change to another version of python globally via pyenv, the `aws` command within the venv will break again unless you again reinstall `awscli` in each globally selected python. I don't have a good fix to suggest because I'm not current on writing of Windows shell scripts, but imagine it involves a different way of discovering python that gives strong preference to a venv if one is active, e.g., by noticing there is a `%VIRTUAL_ENV%` in effect and just invoking `python`(since virtual envs always have a `python`) or `%VIRTUAL_ENV%\scripts\python` if you're wanting to be double-sure. Note that I was able to reproduce this problem on my professional desktop version of Windows 10 at my home as well, so it's nothing specific to the EC2 itself, that's just a way to show that this problem can be demonstrated in a clean environment. The problem seems pretty definitely in the `awscli` library. Whatever solution you pick, I hope this illustrates the issue clearly enough that you can quickly issue some sort of fix to the `awscli` library because the present situation is just plain broken and this is impacting some instructions we're trying to give some users about how to access our system remotely. I'd rather not be advising users to edit scripts they got from elsewhere, nor do I want to supply alternate scripts for them to use. Things should just work.
1
answers
0
votes
92
views
profile picture
asked 2 months ago

Debug AWS_IO_FILE_VALIDATION_FAILURE while trying to connect to aws IoT with custom client certificate

I failed to run the sample code for [basic_connect](https://github.com/aws/aws-iot-device-sdk-cpp-v2/tree/main/samples/mqtt/basic_connect). While running it with the following argument: `basic_connect.exe --client_id "ME" --endpoint "*-ats.iot.eu-west-1.amazonaws.com" --cert "<>/MyCertificate.crt" --key "<>/MyPrivate.key" --verbosity "Debug"` i receive the following output: ``` [DEBUG] [2022-09-29T13:02:54Z] [00001648] [mqtt-client] - client=*: Initalizing MQTT client [DEBUG] [2022-09-29T13:02:56Z] [00001648] [tls-handler] - static: This library was built with Windows 8.1 or later, probing OS to see what we're actually running on. [DEBUG] [2022-09-29T13:02:56Z] [00001648] [tls-handler] - static: We're running on Windows 8.1 or later. ALPN is available. [DEBUG] [2022-09-29T13:02:56Z] [00001648] [tls-handler] - static: This library was built with Windows 8.1 or later, probing OS to see what we're actually running on. [DEBUG] [2022-09-29T13:02:56Z] [00001648] [tls-handler] - static: We're running on Windows 8.1 or later. ALPN is available. [DEBUG] [2022-09-29T13:02:56Z] [00001648] [tls-handler] - static: certificate and key have been set, setting them up now. [INFO] [2022-09-29T13:02:56Z] [00001648] [pki-utils] - static: loading certificate chain with 1 certificates. [ERROR] [2022-09-29T13:03:04Z] [00001648] [pki-utils] - static: no acceptable private key found, error AWS_IO_FILE_VALIDATION_FAILURE [ERROR] [2022-09-29T13:03:04Z] [00001648] [tls-handler] - static: failed to import certificate and private key with error 1038. Client Configuration initialization failed with error aws-c-io: AWS_IO_FILE_VALIDATION_FAILURE, A file was read and the input did not match the expected value ``` I have been trying to follow this AWS_IO_FILE_VALIDATION_FAILURE, and i endup with the following callstack: ``` basic-connect.exe!aws_import_key_pair_to_cert_context(aws_allocator * alloc, const aws_byte_cursor * public_cert_chain, const aws_byte_cursor * private_key, bool is_client_mode, void * * store, const _CERT_CONTEXT * * certs, unsigned __int64 * crypto_provider, unsigned __int64 * private_key_handle) Line 691 C basic-connect.exe!s_ctx_new(aws_allocator * alloc, const aws_tls_ctx_options * options, bool is_client_mode) Line 2010 C basic-connect.exe!aws_tls_client_ctx_new(aws_allocator * alloc, const aws_tls_ctx_options * options) Line 2044 C basic-connect.exe!Aws::Crt::Io::TlsContext::TlsContext(Aws::Crt::Io::TlsContextOptions & options, Aws::Crt::Io::TlsMode mode, aws_allocator * allocator) Line 423 C++ basic-connect.exe!Aws::Iot::MqttClientConnectionConfigBuilder::Build() Line 493 C++ basic-connect.exe!Utils::CommandLineUtils::GetClientConnectionForMQTTConnection(Aws::Iot::MqttClient * client, Aws::Iot::MqttClientConnectionConfigBuilder * clientConfigBuilder) Line 542 C++ basic-connect.exe!Utils::CommandLineUtils::BuildDirectMQTTConnection(Aws::Iot::MqttClient * client) Line 459 C++ basic-connect.exe!main(int argc, char * * argv) Line 41 C++ [External Code] ``` None of the call to `CryptDecodeObjectEx` will succeed in the function `aws_import_key_pair_to_cert_context`. It sounds like there is a problem with my private key which i generated as follow: `openssl req -newkey rsa:4096 -sha256 -nodes -keyout MyPrivate.key -out MyRequest.csr -config MyConfig.cnf` I am not sure to understand what this function is meant to do and what is wrong with my key. I am using win10 with msbuild (tryied in python as well).
2
answers
0
votes
63
views
asked 2 months ago