SSL questions

wlxxiii_

Senior Member
Joined
Jan 31, 2007
Messages
1,506
Reaction score
33
Hi guys,

So I have been able to access my company's intranet thru python by using the cert created in this manner:
NMg7R2k.png


i didn't have to supply a private key to get python to grab data from intranet site.

Now I need to use the following package:
https://twisted.readthedocs.io/en/latest/core/howto/ssl.html

SMLwt63.png


my cert is a .pem file. There is no private key in it. from the pic it seems like i need to generate a private key but doesn't make sense as I can access just by using the cert. Any ideas how to use the twisted SSL library?
 
Last edited:

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
13,547
Reaction score
1,301
Hi guys,

So I have been able to access my company's intranet thru python by using the cert created in this manner:
NMg7R2k.png


i didn't have to supply a private key to get python to grab data from intranet site.

Now I need to use the following package:
https://twisted.readthedocs.io/en/latest/core/howto/ssl.html

SMLwt63.png


my cert is a .pem file. There is no private key in it. from the pic it seems like i need to generate a private key but doesn't make sense as I can access just by using the cert. Any ideas how to use the twisted SSL library?

Are you implementing the client or the server?

For one-way SSL, meaning client verify the server is who the server claimed to be, the server will require a private key so that the server certificate request can be signed by itself or private/public CA to produce a server certificate.

The client do not require the server private key, nor do the client need to produce a private key.

Only in the case of mutual SSL where client will require a private key to generate a certificate request and signed for verification by the server end. I doubt your case is as such.

So which end of the networking are you implementing? I assume you are the client end trying to access a web service at the server end which is protected via SSL?
 

wlxxiii_

Senior Member
Joined
Jan 31, 2007
Messages
1,506
Reaction score
33
From your description should be client side. Yes, trying to access the server aka company intranet

Sent from OnePlus ONEPLUS A6000 using GAGT
 

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
13,547
Reaction score
1,301
From your description should be client side. Yes, trying to access the server aka company intranet

Sent from OnePlus ONEPLUS A6000 using GAGT

First of all, I'm not expertly versed in Python, nor into the event driven Twisted framework, so there are areas I may not be able to dwell deeply into. So I will try to help you from knowledge on SSL/HTTPS.

In your earlier post from the following piece of information
NMg7R2k.png


That is not private key related. It is the certificates chain. Normally your system will have a set of prepopulated root and intermediary certificates that is globally recognised. Some examples are like root certificates from Go Daddy, Verisign, Symantec, Comodo, Amazon, Thawte, etc...

If your system is public system, which are identified using a public hostname/domainname, then they are "normally" installed with certificates signed by one of these Public Certificate Authorities(CA). In this case, your python code will not require to supply certificate chain information/file.

When you client code attempt to connect to the server, part of the SSL negotiation dialogue is to present its public certificate to the client. The client will attempt to trace all the way to a trusted root certificate already installed in the system. If it can be done successfully, then the SSL connection is validated. If not, then the SSL is considered unsafe and should be revoked.

Should your company server is using self-signed certificate, or privately signed CA, then you will need to install the self-signed certificate or the private CA that is signing the server certificate into the client system that is running the code. Doing so will allow validation of the server certificate.

In the image above, the orange portion is the server certificate, the green portion may or may not exist or can even have multiples is the intermediate certificates that sign the server certificate. The blue portion is the root certificate that sign the intermediate certificates or the server certificates.

There are more details to this certificates validation process which I don't want to dwell into for the information above would take you sometime to digest already.

You don't have to resort to the method provided.

The fragment of codes from echoclient_ssl.py is explicitly referring to such a certificate chain file.
Code:
certData = getModule(__name__).filePath.sibling('public.pem').getContent()
authority = ssl.Certificate.loadPEM(certData)
options = ssl.optionsForClientTLS(u'example.com', authority)

You can do so using
Code:
#certData = getModule(__name__).filePath.sibling('public.pem').getContent()
#authority = ssl.Certificate.loadPEM(certData)
options = ssl.optionsForClientTLS(u'example.com')

if the server certificate return by example.com is publicly signed, or signed by a private CA, or self-signed and the root certificate is found in your system running the python client code.

I hope this helps to clarify the certificate doubts.
 

wlxxiii_

Senior Member
Joined
Jan 31, 2007
Messages
1,506
Reaction score
33
That was extremely helpful David! Thanks so much for taking the time to explain in detail, certainly have more clarity now!

Sent from OnePlus ONEPLUS A6000 using GAGT
 

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
13,547
Reaction score
1,301
That was extremely helpful David! Thanks so much for taking the time to explain in detail, certainly have more clarity now!

Sent from OnePlus ONEPLUS A6000 using GAGT

More information, you will need to dig further on this topic. Ask more when you have more concrete doubts :)

https://knowledge.digicert.com/solution/SO16297
https://medium.com/@kasunpdh/ssl-handshake-explained-4dabb87cdce
 
Important Forum Advisory Note
This forum is moderated by volunteer moderators who will react only to members' feedback on posts. Moderators are not employees or representatives of HWZ Forums. Forum members and moderators are responsible for their own posts. Please refer to our Community Guidelines and Standards and Terms and Conditions for more information.
Top