Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8952321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:50:57+00:00 2026-06-15T13:50:57+00:00

I am developing a RESTful web service with Bottle, probably soon to migrate to

  • 0

I am developing a RESTful web service with Bottle, probably soon to migrate to Werkzeug. I’d like to implement an auth scheme that works based on a private/public key pair where the server only has to store the public part while the user keeps the private one. Upon access, the server would require the accessor to perform an action using the private key that the server can verify and relate to the public key part. Upon success, for example a token is generated which can be used for some time. What is the path to implement something like this for Werkzeug or Bottle? Any projects/examples i could work from?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T13:50:57+00:00Added an answer on June 15, 2026 at 1:50 pm

    I believe, the best option here is to shift the responsibility to work with cryptography onto something else. Web servers and CA (certification authorities) are good with it.

    Basically, altogether they can

    1. ensure the connection is secure
    2. ensure the client uses certificate, signed by valid (say, yours) CA
    3. ensure the the certificate hasn’t been revoked
    4. provide to your application the only information you need: the identifier of the remote party

    We use such mechanism to authenticate a third-party payment service (sorry, private code), and there is also a plugin to Redmine providing the same mechanism of client authorization, and we use it too (certainly, it’s Ruby, but it’s also a valid proof that such services can be found in wild.)

    To make things work, all you need is to

    1. configure your CA.
    2. configure your web-server to ensure it accepts certificates by your authority, and only these certificates, and passes the client id further to your app.
    3. ensure your application can extract client identifier from request.

    Below is an tiny example with easyrsa, nginx, uWsgi and werkzeug

    Configure CA

    The easyrsa toolkit is a part of OpenVPN installation. It’s possible to use OpenSSL “raw” command or PyOpenSSL, but easyrsa is convenient and suitable at least at the concept stage.

    cp -a /usr/share/doc/openvpn/examples/easy-rsa/2.0 /etc/nginx/easyrsa
    cd /etc/nginx/easyrsa && source vars && ./clean-all
    

    Create CA

    ./build-ca
    

    Create server certificate

    ./build-key --server server
    

    Create client certificate.

    ./build-key-pkcs12  client1
    

    In the sample above you create both client secret key and its corresponding public part (certificate), but good practice assumes that you sign client certificate requests instead, and has no access to secret part.

    Some services generate a pair of secret key + certificate for you and then write a message on download page like “this is the only chance for you to download the secret key. We don’t store it, so it cannot be download later.”

    Additionally, this command creates a PKCS12 file with encrypted key and certificate, which is handy for import to browsers.

    Configure nginx

    First, we should create a pair “server certificate + ca certificate”, as our CA self-signed:

    cat keys/server.crt keys/ca.crt > keys/server_and_ca.crt
    

    Then the following config can be applied:

    server {
        listen 443;
    
        location / {
            # Here we define the name and the contents of the WSGI variable to pass to service
            uwsgi_param SSL_CLIENT_ID $ssl_client_s_dn;
            include uwsgi_params;
            uwsgi_pass 127.0.0.1:5000;
        }
    
    
        # SSL support
        ssl                 on;
        ssl_protocols       SSLv3 TLSv1;
        ssl_certificate     easyrsa/keys/ca_and_server.crt;
        ssl_certificate_key easyrsa/keys/server.key;
    
        # We don't accept anyone without correct client certificate
        ssl_verify_client on;
        # The CA we use to verify client certificates
        ssl_client_certificate easyrsa/keys/ca.crt;
    }
    

    More information on configuration options is available here and here.

    Ensure you have correct privileges to the /etc/nginx/easyrsa directory and only root and nginx can get access to secret keys.

    Write a Werkzeug application

    The python part is trivial. Just read the variable SSL_CLIENT_ID from WSGI environment.

    The contents of the sample application in file sample.py

    from werkzeug.wrappers import Response
    
    def application(environ, start_response):
        text = 'Hello, your certificate id is %s\n' % environ.get('SSL_CLIENT_ID', '(unknown)')
        response = Response(text, mimetype='text/plain')
        return response(environ, start_response)
    

    Launch the service with a uwsgi server: uwsgi -w sample:application --socket 127.0.0.1:5000

    Test your installation

    It’s easy to test with curl

    $ curl --cert keys/client1.crt --key keys/client1.key --cacert keys/ca.crt https://localhost/
    Hello, your certificate id is /C=US/ST=CA/L=SanFrancisco/O=Fort-Funston/OU=changeme/CN=client1/name=changeme/emailAddress=mail@host.domain
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing a JERSEY RESTFUL web service which has a function that accept an
I'm developing a RESTful web service with WCF and C#. The service works fine,
I wanted to ask again my Question. I'm developing a restful web service that
I am developing an iPhone application using restful web service.I want to implement splash
I have a RESTful service that I am developing in WCF . I am
I am developing a Restful Web Service using Jersey between my Android, iPhone apps
I am developing a RESTful web service using JAX-RS. I am using JAXB to
I using developing a RESTFul web service using Maven and Spring Roo. In my
I am developing a client app for a RESTful web service. The web app
I am developing a Android app, which communicates with a RESTful WCF Web Service

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.