SlideShare a Scribd company logo
1 of 21
Download to read offline
Django-sem,
how to make SignedEmailMessage
out of EmailMessage in few simple
             steps.
           Jakub Wasielak, 2012
Identity verification

  Why?
● Easier bureaucracy


●   Fraud prevention
●   Enabling law
●   Interpersonal communication
Identity verification

  How?
● Ancient times




Mostly verbal verification
Identity verification

  How?
● Ancient times      Mostly verbal verification
●   Middle Ages


    Sealing wax
Identity verification

  How?
● Ancient times       Mostly verbal verification
●   Middle Ages        Sealing wax
●   Before internet

    Stamps
Identity verification

  How?
● Ancient times       Mostly verbal verification
●   Middle Ages        Sealing wax
●   Before internet    Stamps
●   Now

    S/MIME
Public-key infrastructure

Creating, managing, using, storing, and
revoking Digital Certificates.
Public-key infrastructure

All the stuff connected with
           Digital Certificates.
Public-key infrastructure

All the stuff connected with
           Digital Certificates.

CA – Certificate Authority – the unit capable
of issuing and verifying the digital
certificates.
Digital Certificate

    X.509 (PKI)
●   Signature Algorithm – selected by CA
●   Issuer – CA itself
●   Subject – your data
●   Subject Public Key – your public key
●   Certificate signature – the actual signature
●   Version, Serial Number, Validity
Digital Certificate
Certificate:
 Data:
    Version: 1 (0x0)
    Serial Number: 7829 (0x1e95)
    Signature Algorithm: md5WithRSAEncryption
    Issuer: C=ZA, ST=Western Cape, L=Cape Town, O=Thawte Consulting cc,
          OU=Certification Services Division,
          CN=Thawte Server CA/emailAddress=server-certs@thawte.com
    Validity
        Not Before: Jul 9 16:04:02 1998 GMT
        Not After : Jul 9 16:04:02 1999 GMT
    Subject: C=US, ST=Maryland, L=Pasadena, O=Brent Baccala,
           OU=FreeSoft, CN=www.freesoft.org/emailAddress=baccala@freesoft.org
    Subject Public Key Info:
        Public Key Algorithm: rsaEncryption
        RSA Public Key: (1024 bit)
          Modulus (1024 bit):
             00:b4:31:98:0a:c4:bc:62:c1:88:aa:dc:b0:c8:bb:
             ...
             e8:35:1c:9e:27:52:7e:41:8f
          Exponent: 65537 (0x10001)
 Signature Algorithm: md5WithRSAEncryption
    93:5f:8f:5f:c5:af:bf:0a:ab:a5:6d:fb:24:5f:b6:59:5d:9d:
    ...
    8f:0e:fc:ba:1f:34:e9:96:6e:6c:cf:f2:ef:9b:bf:de:b5:22
Signed mail in
          Thunderbird
Signed mail in
             Outlook
Signed mail in
       some apple client
Signed mail in
              Gmail




     ?
Signing – first steps
MeTooCrypto:

M2Crypto is the most complete Python
wrapper for OpenSSL featuring RSA, DSA,
DH, HMACs, message digests, symmetric
ciphers, SSL functionality, HTTPS, urllib,
xmlrpclib, HMAC'ing AuthCookies,
FTP/TLS, S/MIME, ZserverSSL and
ZSmime.
Signing – first steps
MeTooCrypto:

M2Crypto is not well documented.
SignedEmailMessage – a week later
 1. Add 'SEM' into INSTALLED_APPS.
 2. Add DEFAULT_CHARSET and
 AUTH_CERT into setting.
 3. Use it.
1. Add 'SEM' into INSTALLED_APPS.

 pip install django-sem

   INSTALLED_APPS = (
       ...
       'SEM',
       ...
       )
2. Add DEFAULT_CHARSET and
AUTH_CERT into setting.
 DEFAULT_CHARSET = 'utf-8'
 AUTH_CERT = "resources/cert.pem"

/resources/cert.pem

   -----BEGIN CERTIFICATE-----
   AGSJGAS34BDS4htg0234gADSG923ng92G3h2tgjs9afgf
   ...
   ...
   j892th39gSAHGy329hggeZHDg89hegZGDSHY0==
   -----END CERTIFICATE-----




The CA certificate. Available at CA site.
3. Use it.
 Normal EmailMessage usage
 from django.core.mail import EmailMessage

 msg = EmailMessage(
             subject, message_body, sender, recipient_list,
             attachments=attachments)
 msg.send()



SignedEmailMessage usage

  from SEM import SEMail

  msg = SEMail.SignedEmailMessage(
              subject, message_body, sender, recipient_list,
              attachments=attachments,
              from_key=from_key, from_cert=from_cert)
  msg.send()

More Related Content

Similar to Django SEM

Similar to Django SEM (20)

Dirty Little Secrets They Didn't Teach You In Pentest Class v2
Dirty Little Secrets They Didn't Teach You In Pentest Class v2Dirty Little Secrets They Didn't Teach You In Pentest Class v2
Dirty Little Secrets They Didn't Teach You In Pentest Class v2
 
Dirty Little Secrets They Didn't Teach You In Pentest Class v2
Dirty Little Secrets They Didn't Teach You In Pentest Class v2Dirty Little Secrets They Didn't Teach You In Pentest Class v2
Dirty Little Secrets They Didn't Teach You In Pentest Class v2
 
Best Practices of IoT in the Cloud
Best Practices of IoT in the CloudBest Practices of IoT in the Cloud
Best Practices of IoT in the Cloud
 
hackcon2013-Dirty Little Secrets They Didn't Teach You In Pentesting Class v2
hackcon2013-Dirty Little Secrets They Didn't Teach You In Pentesting Class v2hackcon2013-Dirty Little Secrets They Didn't Teach You In Pentesting Class v2
hackcon2013-Dirty Little Secrets They Didn't Teach You In Pentesting Class v2
 
Steam Learn: HTTPS and certificates explained
Steam Learn: HTTPS and certificates explainedSteam Learn: HTTPS and certificates explained
Steam Learn: HTTPS and certificates explained
 
Best Practices for IoT Security in the Cloud
Best Practices for IoT Security in the CloudBest Practices for IoT Security in the Cloud
Best Practices for IoT Security in the Cloud
 
Introduction to Cryptography
Introduction to CryptographyIntroduction to Cryptography
Introduction to Cryptography
 
Cisco Connect Ottawa 2018 secure on prem
Cisco Connect Ottawa 2018 secure on premCisco Connect Ottawa 2018 secure on prem
Cisco Connect Ottawa 2018 secure on prem
 
AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst...
AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst...AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst...
AWS re:Invent 2016: Encryption: It Was the Best of Controls, It Was the Worst...
 
Best Practices for IoT Security in the Cloud
Best Practices for IoT Security in the CloudBest Practices for IoT Security in the Cloud
Best Practices for IoT Security in the Cloud
 
Java security
Java securityJava security
Java security
 
What is SSL/TLS, 1-way and 2-way SSL?
What is SSL/TLS, 1-way and 2-way SSL?What is SSL/TLS, 1-way and 2-way SSL?
What is SSL/TLS, 1-way and 2-way SSL?
 
Shameful secrets of proprietary network protocols
Shameful secrets of proprietary network protocolsShameful secrets of proprietary network protocols
Shameful secrets of proprietary network protocols
 
Secure socket layer
Secure socket layerSecure socket layer
Secure socket layer
 
CONFidence 2014: Jakub Kałużny: Shameful secrets of proprietary protocols
CONFidence 2014: Jakub Kałużny: Shameful secrets of proprietary protocolsCONFidence 2014: Jakub Kałużny: Shameful secrets of proprietary protocols
CONFidence 2014: Jakub Kałużny: Shameful secrets of proprietary protocols
 
Secrity project keyvan
Secrity project   keyvanSecrity project   keyvan
Secrity project keyvan
 
[Wroclaw #8] TLS all the things!
[Wroclaw #8] TLS all the things![Wroclaw #8] TLS all the things!
[Wroclaw #8] TLS all the things!
 
[KGC 2010] 게임과 보안, 암호 알고리즘과 프로토콜
[KGC 2010] 게임과 보안, 암호 알고리즘과 프로토콜[KGC 2010] 게임과 보안, 암호 알고리즘과 프로토콜
[KGC 2010] 게임과 보안, 암호 알고리즘과 프로토콜
 
Is your mobile app as secure as you think?
Is your mobile app as secure as you think?Is your mobile app as secure as you think?
Is your mobile app as secure as you think?
 
Hardening cassandra for compliance or paranoia
Hardening cassandra for compliance or paranoiaHardening cassandra for compliance or paranoia
Hardening cassandra for compliance or paranoia
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 

Django SEM

  • 1. Django-sem, how to make SignedEmailMessage out of EmailMessage in few simple steps. Jakub Wasielak, 2012
  • 2. Identity verification Why? ● Easier bureaucracy ● Fraud prevention ● Enabling law ● Interpersonal communication
  • 3. Identity verification How? ● Ancient times Mostly verbal verification
  • 4. Identity verification How? ● Ancient times Mostly verbal verification ● Middle Ages Sealing wax
  • 5. Identity verification How? ● Ancient times Mostly verbal verification ● Middle Ages Sealing wax ● Before internet Stamps
  • 6. Identity verification How? ● Ancient times Mostly verbal verification ● Middle Ages Sealing wax ● Before internet Stamps ● Now S/MIME
  • 7. Public-key infrastructure Creating, managing, using, storing, and revoking Digital Certificates.
  • 8. Public-key infrastructure All the stuff connected with Digital Certificates.
  • 9. Public-key infrastructure All the stuff connected with Digital Certificates. CA – Certificate Authority – the unit capable of issuing and verifying the digital certificates.
  • 10. Digital Certificate X.509 (PKI) ● Signature Algorithm – selected by CA ● Issuer – CA itself ● Subject – your data ● Subject Public Key – your public key ● Certificate signature – the actual signature ● Version, Serial Number, Validity
  • 11. Digital Certificate Certificate: Data: Version: 1 (0x0) Serial Number: 7829 (0x1e95) Signature Algorithm: md5WithRSAEncryption Issuer: C=ZA, ST=Western Cape, L=Cape Town, O=Thawte Consulting cc, OU=Certification Services Division, CN=Thawte Server CA/emailAddress=server-certs@thawte.com Validity Not Before: Jul 9 16:04:02 1998 GMT Not After : Jul 9 16:04:02 1999 GMT Subject: C=US, ST=Maryland, L=Pasadena, O=Brent Baccala, OU=FreeSoft, CN=www.freesoft.org/emailAddress=baccala@freesoft.org Subject Public Key Info: Public Key Algorithm: rsaEncryption RSA Public Key: (1024 bit) Modulus (1024 bit): 00:b4:31:98:0a:c4:bc:62:c1:88:aa:dc:b0:c8:bb: ... e8:35:1c:9e:27:52:7e:41:8f Exponent: 65537 (0x10001) Signature Algorithm: md5WithRSAEncryption 93:5f:8f:5f:c5:af:bf:0a:ab:a5:6d:fb:24:5f:b6:59:5d:9d: ... 8f:0e:fc:ba:1f:34:e9:96:6e:6c:cf:f2:ef:9b:bf:de:b5:22
  • 12. Signed mail in Thunderbird
  • 13. Signed mail in Outlook
  • 14. Signed mail in some apple client
  • 15. Signed mail in Gmail ?
  • 16. Signing – first steps MeTooCrypto: M2Crypto is the most complete Python wrapper for OpenSSL featuring RSA, DSA, DH, HMACs, message digests, symmetric ciphers, SSL functionality, HTTPS, urllib, xmlrpclib, HMAC'ing AuthCookies, FTP/TLS, S/MIME, ZserverSSL and ZSmime.
  • 17. Signing – first steps MeTooCrypto: M2Crypto is not well documented.
  • 18. SignedEmailMessage – a week later 1. Add 'SEM' into INSTALLED_APPS. 2. Add DEFAULT_CHARSET and AUTH_CERT into setting. 3. Use it.
  • 19. 1. Add 'SEM' into INSTALLED_APPS. pip install django-sem INSTALLED_APPS = ( ... 'SEM', ... )
  • 20. 2. Add DEFAULT_CHARSET and AUTH_CERT into setting. DEFAULT_CHARSET = 'utf-8' AUTH_CERT = "resources/cert.pem" /resources/cert.pem -----BEGIN CERTIFICATE----- AGSJGAS34BDS4htg0234gADSG923ng92G3h2tgjs9afgf ... ... j892th39gSAHGy329hggeZHDg89hegZGDSHY0== -----END CERTIFICATE----- The CA certificate. Available at CA site.
  • 21. 3. Use it. Normal EmailMessage usage from django.core.mail import EmailMessage msg = EmailMessage( subject, message_body, sender, recipient_list, attachments=attachments) msg.send() SignedEmailMessage usage from SEM import SEMail msg = SEMail.SignedEmailMessage( subject, message_body, sender, recipient_list, attachments=attachments, from_key=from_key, from_cert=from_cert) msg.send()