Updates from April, 2012 Toggle Comment Threads | Keyboard Shortcuts

  • Richard 2:30 pm on April 25, 2012 Permalink |  

    How to avoid the trust question 

    Certain software installs (particularlyĀ those that install drivers) ask this question:

    …which is a difficult one to answer when the installation is unattended.

    To bypass this, you need to add the publisher’s certificate in the localmachine, ‘Trusted Publishers’ certificate store. The easiest way to obtain the certificate is to install the software manually, and export the certificate to a file.

    This certmgr command will install the certificate for you:

    certmgr.exe -add cert.cer -c -s -r localMachine TrustedPublisher
     
     
  • Richard 9:37 am on April 10, 2012 Permalink |  

    Access blob storage using basic authentication 

    This node.js snippet will start a web server which uses basic authentication (username and password) to provide access to blob storage (i.e. private containers). You should enter the storage name and access key as the username and password.

    WARNING: Be careful when disclosing your storage account key, basic authentication is not encrypted.

    var http = require('http');
    var azure = require('azure');
    
    http.createServer(function (request, response) {
        if (request.headers.authorization) {
            var userAndPassword = decodeBasicAuth(request);
            var blobService = azure.createBlobService(userAndPassword.username, userAndPassword.password, "blob.core.windows.net").withFilter(new azure.ExponentialRetryPolicyFilter());
            var path = request.url.split('/');
    
            if (path.length >= 3) {
                getBlob(path[1], request.url.substring(path[1].length + 2), response, blobService);
            }
            else {
                getBlob("$root", request.url.substring(1), response, blobService);
            }
        }
        else {
            response.writeHead(401, {"WWW-Authenticate": 'Basic realm="Azure Storage"'});
            response.end();
        }
    }).listen(80);
    
    function decodeBasicAuth(request) {
        if (request.headers.authorization) {
            var encodedheader = request.headers.authorization.replace("Basic ", "");
            var decodedheader = new Buffer(encodedheader, 'base64').toString('ascii');
            var userAndPassword = decodedheader.split(":");
            return { username: userAndPassword[0], password: userAndPassword[1] };
        }
        return {};
    }
    
    function getBlob(container, blob, response, blobService) {
        blobService.getBlobToStream(container, blob, response, function(error){
            if(!error){
                response.writeHead(200);
                response.end();
            }
            else {
                response.writeHead(404);
                response.end(error);
            }
        });
    }
     
c
Compose new post
j
Next post/Next comment
k
Previous post/Previous comment
r
Reply
e
Edit
o
Show/Hide comments
t
Go to top
l
Go to login
h
Show/Hide help
shift + esc
Cancel