Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GT-185] Update logging in test_crypto #245

Merged
merged 1 commit into from
Aug 1, 2023

Conversation

rowan04
Copy link
Contributor

@rowan04 rowan04 commented Jul 18, 2023

  • removes old comment
  • gets rid of logging.getLogger('SSM')

resolves #244

test output:

[root@host-172-16-105-234 test]# python test_crypto.py
Generating a 2048 bit RSA private key
................................+++
................................................................+++
writing new private key to '/tmp/test.key'
-----
.Generating a 2048 bit RSA private key
..+++
............................................................................+++
writing new private key to '/tmp/test.key'
-----
ERROR:ssm.crypto:unable to load certificate
140315647899536:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:707:Expecting: TRUSTED CERTIFICATE

.Generating a 2048 bit RSA private key
.........................................+++
...........................................................................................+++
writing new private key to '/tmp/test.key'
-----
ERROR:ssm.crypto:unable to load certificate
140567456802704:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:707:Expecting: TRUSTED CERTIFICATE

ERROR:ssm.crypto:unable to load key
140295188965264:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:707:Expecting: ANY PRIVATE KEY

.Generating a 2048 bit RSA private key
................................................................................................................................................+++
........................................................................................................................................+++
writing new private key to '/tmp/test.key'
-----
ERROR:ssm.crypto:Could not find cert or key file: [Errno 2] No such file or directory: 'hello'
ERROR:ssm.crypto:Could not find cert or key file: [Errno 2] No such file or directory: 'k'
ERROR:ssm.crypto:Could not find cert or key file: [Errno 2] No such file or directory: 'c'
.Generating a 2048 bit RSA private key
.+++
.......................................................................+++
writing new private key to '/tmp/test.key'
-----
.Generating a 2048 bit RSA private key
....................+++
...+++
writing new private key to '/tmp/test.key'
-----
.Generating a 2048 bit RSA private key
.+++
......+++
writing new private key to '/tmp/test.key'
-----
ERROR:ssm.crypto:unable to load certificate
140579938973584:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:707:Expecting: TRUSTED CERTIFICATE

ERROR:ssm.crypto:unable to load certificate
140532835903376:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:707:Expecting: TRUSTED CERTIFICATE

.Generating a 2048 bit RSA private key
..............+++
........................................+++
writing new private key to '/tmp/test.key'
-----
.Generating a 2048 bit RSA private key
.......+++
................................................................................................................+++
writing new private key to '/tmp/test.key'
-----
.Generating a 2048 bit RSA private key
......................................................................+++
..........................+++
writing new private key to '/tmp/test.key'
-----
.Generating a 2048 bit RSA private key
.....................................................+++
.......................................................................................................................................+++
writing new private key to '/tmp/test.key'
-----
ERROR:ssm.crypto:Error reading S/MIME message
139928187541392:error:0D0D40D1:asn1 encoding routines:SMIME_read_ASN1:no content type:asn_mime.c:440:

ERROR:ssm.crypto:unable to load PKCS7 object
140338298214288:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:707:Expecting: PKCS7

ERROR:ssm.crypto:unable to load certificate
139704674850704:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:707:Expecting: TRUSTED CERTIFICATE

WARNING:ssm.crypto:Certificate verification:
ERROR:ssm.crypto:Error reading S/MIME message
140515806496656:error:0D0D40D1:asn1 encoding routines:SMIME_read_ASN1:no content type:asn_mime.c:440:

ERROR:ssm.crypto:unable to load PKCS7 object
139981541640080:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:707:Expecting: PKCS7

ERROR:ssm.crypto:unable to load certificate
140001239017360:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:707:Expecting: TRUSTED CERTIFICATE

WARNING:ssm.crypto:Certificate verification:
.Generating a 2048 bit RSA private key
.................+++
............................+++
writing new private key to '/tmp/test.key'
-----
WARNING:ssm.crypto:Certificate verification: stdin: C = UK, O = STFC, OU = SC, CN = Test Cert
error 18 at 0 depth lookup:self signed certificate
OK

ERROR:ssm.crypto:unable to load certificate
140181163296656:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:707:Expecting: TRUSTED CERTIFICATE

WARNING:ssm.crypto:Certificate verification:
WARNING:ssm.crypto:Certificate verification: stdin: C = UK, O = STFC, OU = SC, CN = Test Cert
error 3 at 0 depth lookup:unable to get certificate CRL

.
----------------------------------------------------------------------
Ran 12 tests in 1.573s

OK

@rowan04 rowan04 requested a review from a team as a code owner July 18, 2023 14:47
@rowan04 rowan04 changed the title Update logging in test_crypto [GT-185] Update logging in test_crypto Jul 18, 2023
@rowan04
Copy link
Contributor Author

rowan04 commented Jul 19, 2023

With no logging:

[root@host-172-16-105-234 test]# python test_crypto.py
Generating a 2048 bit RSA private key
......................................................................+++
................................................................+++
writing new private key to '/tmp/test.key'
-----
.Generating a 2048 bit RSA private key
..............................................+++
..................+++
writing new private key to '/tmp/test.key'
-----
No handlers could be found for logger "ssm.crypto"
.Generating a 2048 bit RSA private key
....+++
.........+++
writing new private key to '/tmp/test.key'
-----
.Generating a 2048 bit RSA private key
...........+++
............................................................+++
writing new private key to '/tmp/test.key'
-----
.Generating a 2048 bit RSA private key
.................................+++
.....+++
writing new private key to '/tmp/test.key'
-----
.Generating a 2048 bit RSA private key
.............................................................+++
..................................+++
writing new private key to '/tmp/test.key'
-----
.Generating a 2048 bit RSA private key
...............................................................................+++
.......+++
writing new private key to '/tmp/test.key'
-----
.Generating a 2048 bit RSA private key
.................................................................................................+++
.................................................+++
writing new private key to '/tmp/test.key'
-----
.Generating a 2048 bit RSA private key
........+++
..+++
writing new private key to '/tmp/test.key'
-----
.Generating a 2048 bit RSA private key
.............................+++
...+++
writing new private key to '/tmp/test.key'
-----
.Generating a 2048 bit RSA private key
......................................................................................................................................+++
...................................................................+++
writing new private key to '/tmp/test.key'
-----
.Generating a 2048 bit RSA private key
...................+++
............................................+++
writing new private key to '/tmp/test.key'
-----
.
----------------------------------------------------------------------
Ran 12 tests in 1.366s

OK

@rowan04
Copy link
Contributor Author

rowan04 commented Jul 19, 2023

with log = logging.getLogger('SSM')

[root@host-172-16-105-234 test]# python test_crypto.py
Generating a 2048 bit RSA private key
......................................................+++
..............................+++
writing new private key to '/tmp/test.key'
-----
.Generating a 2048 bit RSA private key
...........................+++
...........+++
writing new private key to '/tmp/test.key'
-----
ERROR:ssm.crypto:unable to load certificate
140228868245392:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:707:Expecting: TRUSTED CERTIFICATE

.Generating a 2048 bit RSA private key
...+++
...................................+++
writing new private key to '/tmp/test.key'
-----
ERROR:ssm.crypto:unable to load certificate
139983351752592:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:707:Expecting: TRUSTED CERTIFICATE

ERROR:ssm.crypto:unable to load key
139967112411024:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:707:Expecting: ANY PRIVATE KEY

.Generating a 2048 bit RSA private key
.................................................+++
..............................................................+++
writing new private key to '/tmp/test.key'
-----
ERROR:ssm.crypto:Could not find cert or key file: [Errno 2] No such file or directory: 'hello'
ERROR:ssm.crypto:Could not find cert or key file: [Errno 2] No such file or directory: 'k'
ERROR:ssm.crypto:Could not find cert or key file: [Errno 2] No such file or directory: 'c'
.Generating a 2048 bit RSA private key
.........+++
..........................................+++
writing new private key to '/tmp/test.key'
-----
.Generating a 2048 bit RSA private key
...............................................................+++
.......................+++
writing new private key to '/tmp/test.key'
-----
.Generating a 2048 bit RSA private key
..+++
..................................................................+++
writing new private key to '/tmp/test.key'
-----
ERROR:ssm.crypto:unable to load certificate
140151230130064:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:707:Expecting: TRUSTED CERTIFICATE

ERROR:ssm.crypto:unable to load certificate
140584681994128:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:707:Expecting: TRUSTED CERTIFICATE

.Generating a 2048 bit RSA private key
........+++
.....................+++
writing new private key to '/tmp/test.key'
-----
.Generating a 2048 bit RSA private key
.................................+++
...........................................+++
writing new private key to '/tmp/test.key'
-----
.Generating a 2048 bit RSA private key
................+++
....................................................................+++
writing new private key to '/tmp/test.key'
-----
.Generating a 2048 bit RSA private key
.....................+++
.....+++
writing new private key to '/tmp/test.key'
-----
ERROR:ssm.crypto:Error reading S/MIME message
139814226032528:error:0D0D40D1:asn1 encoding routines:SMIME_read_ASN1:no content type:asn_mime.c:440:

ERROR:ssm.crypto:unable to load PKCS7 object
140087253772176:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:707:Expecting: PKCS7

ERROR:ssm.crypto:unable to load certificate
139808558294928:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:707:Expecting: TRUSTED CERTIFICATE

WARNING:ssm.crypto:Certificate verification:
ERROR:ssm.crypto:Error reading S/MIME message
139973072541584:error:0D0D40D1:asn1 encoding routines:SMIME_read_ASN1:no content type:asn_mime.c:440:

ERROR:ssm.crypto:unable to load PKCS7 object
140326117586832:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:707:Expecting: PKCS7

ERROR:ssm.crypto:unable to load certificate
139906879678352:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:707:Expecting: TRUSTED CERTIFICATE

WARNING:ssm.crypto:Certificate verification:
.Generating a 2048 bit RSA private key
.................................................+++
.+++
writing new private key to '/tmp/test.key'
-----
WARNING:ssm.crypto:Certificate verification: stdin: C = UK, O = STFC, OU = SC, CN = Test Cert
error 18 at 0 depth lookup:self signed certificate
OK

ERROR:ssm.crypto:unable to load certificate
140153464551312:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:707:Expecting: TRUSTED CERTIFICATE

WARNING:ssm.crypto:Certificate verification:
WARNING:ssm.crypto:Certificate verification: stdin: C = UK, O = STFC, OU = SC, CN = Test Cert
error 3 at 0 depth lookup:unable to get certificate CRL

.
----------------------------------------------------------------------
Ran 12 tests in 1.197s

OK

@rowan04
Copy link
Contributor Author

rowan04 commented Jul 19, 2023

Here is the link to a diffchecker comparing the original test output (using log = logging.getlogger('ssm')) and with that line removed:
https://www.diffchecker.com/AFNWfrAY/

and you can clealry see without a diffchecker the differences between these two and the output with no logging at all

@rowan04
Copy link
Contributor Author

rowan04 commented Jul 19, 2023

Here is the link to a diffchecker comparing the original test output (using log = logging.getlogger('ssm')) and with that line removed: https://www.diffchecker.com/AFNWfrAY/

and you can clealry see without a diffchecker the differences between these two and the output with no logging at all

there is no meaningful difference between the outputs with the two different logging setups, and the output without logging lacks information

@rowan04 rowan04 force-pushed the 244-update-logging-in-test_crypto branch from 6942fc8 to ccbd760 Compare July 19, 2023 10:26
@rowan04
Copy link
Contributor Author

rowan04 commented Jul 19, 2023

reabsed onto latest dev

@tofu-rocketry tofu-rocketry self-assigned this Aug 1, 2023
@tofu-rocketry tofu-rocketry added this to the 3.4.0 milestone Aug 1, 2023
@tofu-rocketry
Copy link
Member

Here is the link to a diffchecker comparing the original test output (using log = logging.getlogger('ssm')) and with that line removed: https://www.diffchecker.com/AFNWfrAY/

and you can clealry see without a diffchecker the differences between these two and the output with no logging at all

The Diffchecker view is useful. Thanks for that.

- removes old comment
- gets rid of logging.getLogger('SSM')
@tofu-rocketry tofu-rocketry force-pushed the 244-update-logging-in-test_crypto branch from ccbd760 to 4e0f977 Compare August 1, 2023 14:10
@tofu-rocketry tofu-rocketry merged commit 83e33c7 into apel:dev Aug 1, 2023
7 of 9 checks passed
@rowan04 rowan04 deleted the 244-update-logging-in-test_crypto branch August 1, 2023 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

outdated logging necessity comment
2 participants