EzDevInfo.com

certificate-authority interview questions

Top certificate-authority frequently asked interview questions

How do I programmatically remove a certificate in Trusted Root Certification Authorities?

I need to be able to remove a specific certificate from each PC in my organization. Yes, I could go seat-to-seat, but I have until Thursday to pull it off, and I don't have the manpower to go seat-to-seat.

Is there a programmatic way of doing this using C#?


Source: (StackOverflow)

Good C++ library for HTTPS connection ? Certificate is signed by a certificate autority

I have 2 questions:

Q1 : Does anyone know a good C++ library to perform requests towards a HTTPS server?

Note that the SSL certificate on the server will be provided by a certificate autority like VeriSign.

Q2 : So, could I embedded the root certificate of the CA in my C++ application so that it will be automatically used by the library? I don't want the user to add it manually in its operating system.

Thanks for your advices.


Source: (StackOverflow)

Advertisements

Solutions to web service client certificates/auth best practices

I have a simple web service that has an API third party developers are allowed to access. The API mostly follows REST principles.

I'm interested in solutions to make the API more secure by requiring developers to use client certificates. Is there any open source solutions or other implementation advice any of you have that would assist in REST based APIs using user level certificates for auth?


Source: (StackOverflow)

What's the difference between class 1 and class 3 roots, and the certificates signed by them?

Pretty much what the question says. What's the difference between the two classes of roots? The differences between the certificates signed by such roots? What uses would a class 1 signed certificate have that a class 3 doesn't, and vice versa?


Source: (StackOverflow)

SecTrustEvaluate fails with kSecTrustResultRecoverableTrustFailure for self signed CA with non-matching subject name

Here's my pretty standard NSURLConnection callback for authenticating using self signed certificate:

- (SecCertificateRef)certRefFromDerNamed:(NSString*)derFileName resultingDataRef:(CFDataRef*)dataRefPtr{
    NSString *thePath = [[NSBundle mainBundle] pathForResource:derFileName ofType:@"der"];
    NSData *certData = [[NSData alloc] initWithContentsOfFile:thePath];
    CFDataRef certDataRef = (__bridge_retained CFDataRef)certData;
    SecCertificateRef cert = SecCertificateCreateWithData(NULL, certDataRef);
    *dataRefPtr = certDataRef;
    return cert;
}

- (void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {

if (connection == self.connection) {

    BOOL trusted = NO;
     if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) {

        SecPolicyRef policyRef = SecPolicyCreateBasicX509();

        SecCertificateRef cert1;
        CFDataRef certData1;

        cert1 = [self certRefFromDerNamed:@"some3rdpartycacert" resultingDataRef:&certData1];

        SecCertificateRef certArray[1] = { cert1 };
        CFArrayRef certArrayRef = CFArrayCreate(NULL, (void *)certArray, 1, NULL);

        SecTrustRef serverTrust = challenge.protectionSpace.serverTrust;
        SecTrustSetAnchorCertificates(serverTrust, certArrayRef);
        SecTrustResultType trustResult;

        SecTrustEvaluate(serverTrust, &trustResult);

        trusted = (trustResult == kSecTrustResultUnspecified);

        CFRelease(certArrayRef);
        CFRelease(policyRef);
        CFRelease(cert1);
        CFRelease(certData1);
    }
    if (trusted) {
        [challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge];
    } else {
        [challenge.sender performDefaultHandlingForAuthenticationChallenge:challenge];
    }
}
}

And trustResult is always kSecTrustResultRecoverableTrustFailure.

The certificate itself is a little problematic. According to curl cert subject name on server does not match the url I'm connecting to. I've contacted that 3rd party company and they told me that I need to accept this url mismatch in my code. The problem is that I don't know how to do this on iOS. I can either bypass the certificate check completely (by simply assuming trusted=YES and calling useCredential) or fail completely. The first solution is obviously wrong from security point of view and prone to MITM attacks.

Here's the CURL output (I've used PEM version for the same cert here):

ukaszs-iMac:Preferences lukasz$  curl --verbose --cacert ~/Desktop/some3rdpartycacert.txt  https://dev-service.some3rdparty.com:50101/
* About to connect() to dev-service.some3rdparty.com port 50101 (#0)
*   Trying XXX.XXX.XXX.XXX...
* connected
* Connected to dev-service.some3rdparty.com (XXX.XXX.XXX.XXX) port 50101 (#0)
* successfully set certificate verify locations:
*   CAfile: /Users/lukasz/Desktop/some3rdpartycacert.txt
  CApath: none
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Request CERT (13):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSL connection using AES256-SHA
* Server certificate:
*    subject: C=CA; ST=Ontario; O=Some 3rdParty Corporation; CN=otherpage.some3rdparty.com; emailAddress=noc@some3rdparty.com
*    start date: 2013-10-30 16:52:14 GMT
*    expire date: 2013-10-30 16:52:14 GMT
* SSL: certificate subject name 'otherpage.some3rdparty.com' does not match target host name 'dev-service.some3rdparty.com'
* Closing connection #0
* SSLv3, TLS alert, Client hello (1):
curl: (51) SSL: certificate subject name 'otherpage.some3rdparty.com' does not match target host name 'dev-service.some3rdparty.com'

So, how to ignore this particular error on iOS?


Source: (StackOverflow)

Advanced SSL: Intermediate Certificate Authority and deploying embedded boxes

Ok Advanced SSL gals and guys - I'll be adding a bounty to this after the two-day period as I think it's a complex subject that deserves a reward for anyone who thoughtfully answers.

Some of the assumptions here are simply that: assumptions, or more precisely hopeful guesses. Consider this a brain-teaser, simply saying 'This isn't possible' is missing the point.

Alternative and partial solutions are welcome, personal experience if you've done something 'similar'. I want to learn something from this even if my entire plan is flawed.

Here's the scenario:

I'm developing on an embedded Linux system and want its web server to be able to serve out-of-the-box, no-hassle SSL. Here's the design criteria I'm aiming for:

Must Haves:

  • I can't have the user add my homegrown CA certificate to their browser
  • I can't have the user add a statically generated (at mfg time) self-signed certificate to their browser
  • I can't have the user add a dynamically generated (at boot time) self-signed certificate to their browser.
  • I can't default to HTTP and have an enable/disable toggle for SSL. It must be SSL.
  • Both the embedded box and the web browser client may or may not have internet access so must be assumed to function correctly without internet access. The only root CAs we can rely on are the ones shipped with operating system or the browser. Lets pretend that that list is 'basically' the same across browsers and operating systems - i.e. we'll have a ~90% success rate if we rely on them.
  • I cannot use a fly-by-night operation i.e. 'Fast Eddie's SSL Certificate Clearing House -- with prices this low our servers MUST be hacked!'

Nice to Haves:

  • I don't want the user warned that the certificate's hostname doesn't match the hostname in the browser. I consider this a nice-to-have because it may be impossible.

Do not want:

  • I don't want to ship the same set of static keys for each box. Kind of implied by the 'can't' list, but I know the risk.

Yes Yes, I know..

  • I can and do provide a mechanism for the user to upload their own cert/key but I consider this 'advanced mode' and out of scope of this question. If the user is advanced enough to have their own internal CA or purchase keys then they're awesome and I love them.

Thinking Cap Time

My experience with SSL has been generating cert/keys to be signed by 'real' root, as well as stepping up my game a little bit with making my own internal CA, distributing internally 'self-signed' certs. I know you can chain certificates, but I'm not sure what the order of operations is. i.e. Does the browser 'walk up' the chain see a valid root CA and see that as a valid certificate - or do you need to have verification at every level?

I ran across the description of intermediate certificate authority which got me thinking about potential solutions. I may have gone from 'the simple solution' to 'nightmare mode', but would it be possible to:

Crazy Idea #1

  • Get an intermediate certificate authority cert signed by a 'real' CA. ( ICA-1 )
    • ROOT_CA -> ICA-1
  • This certificate would be used at manufacturing time to generate a unique passwordless sub-intermediate certificate authority pair per box.
    • ICA-1 -> ICA-2
  • Use ICA-2 to generate a unique server cert/key. The caveat here is, can you generate a key/pair for an IP (and not a DNS name?)? i.e. A potential use-case for this would be the user connects to the box initially via http, and then redirects the client to the SSL service using the IP in the redirect URL (so that the browser won't complain about mismatches). This could be the card that brings the house down. Since the SSL connection has to be established before any redirects can happen, I can see that also being a problem. But, if that all worked magically
  • Could I then use the ICA-2 to generate new cert/key pairs any time the box changes IP so that when the web server comes back up it's always got a 'valid' key chain.
    • ICA-2 -> SP-1

Ok, You're So Smart

Most likely, my convoluted solution won't work - but it'd be great if it did. Have you had a similar problem? What'd you do? What were the trade offs?


Source: (StackOverflow)

Active Directory - Certificate Based Authentication - Multiple certificates for user

First, I have very limited knowledge about AD.

Problem: I authenticating users on AD using user certificates. I want to authenticate user on various devices (including mobile devices). Each will generate its own certificate via a CA. The CA is tied up with AD, so user authenticates on AD via certificates.

On the question is: Can a user account on AD hold multiple certificate for a single user. Because in my case the private key will not be share between devices (Devices will connect with CA to retrieve its own identity cert)

Please help


Source: (StackOverflow)

Does a truststore need the sub-ca certificate?

I'm trying to setup a hierarchical PKI. Can I create a truststore containing only the root ca certificate, and will that mean my application trusts certificates signed by a sub-ca certificate which is in turn signed by the root ca?

As an aside, it seems that you must provide an entire certificate chain, including the root ca certificate. Surely if the root ca is trusted, the certificate shouldn't need to be sent? We just want to check if the next certificate down is signed by it.


Source: (StackOverflow)

Benefits in security to a CA signed SSL certificate

This is just a general question regarding the debate between self-signed certificates and CA certificates...

I understand the benefits for a CA certificate due to the avoided warnings generated in most browsers, but how does a CA certificate benefit actual security? I commonly hear the biggest threat is man-in-the-middle attacks, and while I understand this threat using a self-signed certificate, I don't understand how a CA certificate prevents this. I know CAs perform their own security algorithms couldn't the same algorithms be used on self-signed certificates?

I guess I'm just a little irritated by the big business revolving around the need for CA certificates but can't seem to find anything different about them other then these supposed additional security checks they perform. Is there anything a CA can provide from a security point-of-view that self-signed certificates cannot?


Source: (StackOverflow)

Certificate Authority for myself/small organisation

I need a small CA software which meet following criteria:

  1. CLI Interface (we all really hate gui things for server software, don't we?)
  2. Issuing certificates for websites. So I just can install one root certificate on client machines to get rid of that warnings)
  3. Issuing user certificates (as p12 and other stuff, so I can authenticate using them) with predefined values.

I was looking at tinyca but it's somewhat outdated and didnt worked for me well.

Openssl can do all of this, so I can code a bunch of shell scripts (or maybe Makefile) to automate this task. So I was wondering if already somebody did this?


Source: (StackOverflow)

Replace binary in a file (from java keytool csr) using hexdump sed and xxd?

I am attempting to follow this reply and change a few hex bytes in a file by using hexdump, xxd, and sed.

According to that response, after converting the CSR generated with keytool (which happens to be base-64 PEM format) into DER, I should be able to do a straight bytes replacement, replacing 0x13 with 0x0c.

Here is what I have attempted:

#convert csr pem to der
openssl req -in openfire.csr -outform der -out openfire_csr.der
cat openfire_csr.der | grep -aP '\x13' | md5sum
#e61387f5c1xxxxeb832df102524220d81  - #it has some length
#perform replacement of hex bytes:
sed 's/\x13/\x0c/g' openfire_csr.der
#convert csr der to csr pem:
openssl req -in openfire_csr.der -outform pem -out openfire_utf8.csr
#unable to load X509 request
#3078055660:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:698:Expecting: CERTIFICATE REQUEST

I suspect I'm missing some conversion, but I do not know where.

How do I perform byte replacement using available tools (like sed, xxd, and/or hexdump)?


Source: (StackOverflow)

The template parameter in InitializeFromPrivateKey() on CX509CertificateRequestPkcs10 object causes exception when trying a specific Template

I am having an issue with specifying the template parameter in InitializeFromPrivateKey() on the X509Enrollment.CX509CertificateRequestPkcs10 object. Anything other than a template of "User" is resulting in the following exception:-

CertEnroll::CX509CertificateRequestPkcs10::InitializeFromPrivateKey: The requested certificate template is not supported by this CA. 0x80094800 (-2146875392)

There is a specific Certificate template that I need to be used, and when I try it then the code throws the exception. The template exists on the CA, and on the client machine which is running the following code.

Javascript code as follows:

 <script type="text/javascript">

     var sCertificate = null;
     var sDistinguishedName = "C=\"\";S=\"\";L=\"\";O=\"XXXXX\";OU=\"XXXXXXX\";E=\"XXXXX@XXXX.com\";CN=\"xxxxxxx\";";
     var template = "RegistrationCert"; //Anything Other than "User" fails, have tried template Oid too.

     var classFactory = new ActiveXObject("X509Enrollment.CX509EnrollmentWebClassFactory");
     var objEnroll = classFactory.CreateObject("X509Enrollment.CX509Enrollment");
     var objPrivateKey = classFactory.CreateObject("X509Enrollment.CX509PrivateKey");
     var objRequest = classFactory.CreateObject("X509Enrollment.CX509CertificateRequestPkcs10");
     var objDN = classFactory.CreateObject("X509Enrollment.CX500DistinguishedName");

     objPrivateKey.ProviderName = "Microsoft Enhanced Cryptographic Provider v1.0";
     objPrivateKey.KeySpec = "1";
     objPrivateKey.ProviderType = "1";

    try 
    {
            objRequest.InitializeFromPrivateKey(1, objPrivateKey, template);
            objDN.Encode(sDistinguishedName, 0);
            objRequest.Subject = objDN;
            objEnroll.InitializeFromRequest(objRequest);
            sCertificate = objEnroll.CreateRequest(1);
            document.writeln(sCertificate);
    }
    catch (ex)
    {
             document.writeln(ex.description);
    }
 </script>

Couple of other questions
- I assume that the template should exist on the Client Machine? Otherwise how does it know the location of the CA to query for templates?
- Does CertEnroll on a Client even work against a Windows 2003 CA server??

If you can help me that it would be much appreciated!!!

Additional Info
- Client is Windows 7, with MS IE9 Client running as Administrator.
- Web App which hosts the above page is accessed over HTTPs.
- Web App is hosted on a Win2003 CA Server.

Before posting I have looked at...
- Stackoverflow threads regarding CertEnroll + InitializeFromPrivateKey
- Blogs about using Template OID not Template name
- MSDN / alejacma's Site
- CertEnroll API on MSDN


Source: (StackOverflow)

OpenSSL Verify Peer (Client) Certificate in C++

I have a working application that establishes an SSL connection to a server. The server uses a self-signed certificate and the client loads a certificate authority chain to tell it that the server is OK to trust. I did that with code like this on the client:

SSL_METHOD* method = TLSv1_client_method();
_ctx = SSL_CTX_new(method);
if ( SSL_CTX_load_verify_locations(_ctx, "ca-all.crt", NULL) != 1 )
{
    return false;
}
_ssl = SSL_new(_ctx);
int val = SSL_set_fd(_ssl, _socket->GetFD());
if ( val != SSL_SUCCESS )
{
    int err = SSL_get_error(_ssl, val);
    return false;
}
val = SSL_connect(_ssl);

And on the server:

  if ( SSL_CTX_use_certificate_chain_file( g_ctx, "ca-chain1.crt" ) <= 0 ) {
    return 1;
  }
  ppem_file = getenv( "PEM_FILE" );
  if ( ppem_file == NULL ) {
    ppem_file = pem_file;
  }
  if ( SSL_CTX_use_certificate_file( g_ctx, ppem_file,
                                     SSL_FILETYPE_PEM ) <= 0 ) {
    return 1;
  }
  if ( SSL_CTX_use_PrivateKey_file( g_ctx, ppem_file,
                                    SSL_FILETYPE_PEM ) <= 0 ) {
    return 2;
  }

I'm trying to modify this code so that the server also verifies the client's peer certificate (self-signed, using same issuer as the server) and having a bit of trouble. I haven't found good "conceptual overview" documentation anywhere, and that seems to be a typical hurdle with the OpenSSL libraries.

On the client I added this after the SSL_CTX_load_verify_locations() call:

if ( SSL_CTX_use_certificate_file(_ctx, "generic_client.pem", SSL_FILETYPE_PEM ) != 1 )
{
    return false;
}

On the server I added this after the SSL_CTX_use_PrivateKey_file() call:

  STACK_OF(X509_NAME) *list;
  list = SSL_load_client_CA_file( "ca_chain2.crt" );
  if( list == NULL ) {
    return 4;
  }
  SSL_CTX_set_client_CA_list( g_ctx, list );
  SSL_CTX_set_verify( g_ctx, SSL_VERIFY_PEER, NULL );

The connection fails because the certificate doesn't validate. The client seems to load the certificate fine and if I comment out the SSL_CTX_set_verify line, the client connects without trouble (because its certificate is never verified).

It seems that the server doesn't think that the client's certificate authority chain is good. What am I missing here?

From the commandline I can run: openssl verify -CAfile ca-chain2.crt generic_client.pem And it passes, so I have the right certificate data available, I must just be using it wrong somehow.


Source: (StackOverflow)

Where does makecert.exe store the digital certificate

I created a self-signed certificate and a client certificate using this tutorial and the makecert.exe tool:

http://msdn.microsoft.com/en-us/library/ff647171.aspx

However, when I go to MMC and try to import the certificate in the Trusted Root Certificate Authorities, I have no clue where to locate the .cer file.

Where does the makecert.exe tool save the certificates it creates?


Source: (StackOverflow)

How to resolve "enter the password for credential storage" issue?

So I am playing around with fiddler web proxy. I need to decrypt https traffic. So I am trying to put the fiddler root CA cert in my device trust store. But it keeps asking me "Enter the password for credential storage". If i enter anything and click enter I see an Toast message saying

Credential storage has been erased

and the password prompt comes again. This goes on in a loop. For the record I have selected "Wifi" as the Credential use instead of "App n VPN" (not sure of that matters).

enter image description here

Next wired thing that I noticed is that after each prompt the description changes for label

The package contains

The value for it increases each time the password prompt is shown. For eg - 3 CA certificates, 4 CA certificates and so on...

enter image description here

As much as I want my device to accept this certificate I would appreciate if someone could explain the "credential storage" concept and the weird increment of CA certs text.


Source: (StackOverflow)