/* * Copyright (C) 2008 by Sericon Technology Inc. * http://www.sericontech.com * All rights reserved. * * This software is supplied under the terms of a licence agreement or * non-disclosure agreement with Sericon Technology Inc. and may not be * copied nor disclosed except in accordance with the terms of that agreement. * * * Module Name: * * AutoSSLClient.c * * Abstract: * * This is an example AutoSSL application. * */ #include #include "PRAErrors.h" #include "ProductRegistrationAgent.h" #include "BasicCustomerInfo.h" #include "PRACertificate.h" #include "GetData.h" #define BASE_DOMAIN "acmewebcam.com" int main(int argc, char **argv) { // Create and initialize the PRA int rc = AutoSSL_CreatePRA("acer.autossl.com", // Address of AutoSSL Server "AutoSSL Demo for C", // Name of this application "1.0", // Application's version "d:\\AutoSSLTest", // Where to write data "US_en"); // Locale for generated text if (rc) { // Check to see if there's a certificate already // If there is one, we'll just read the old information, and perform a renewal if (AutoSSL_HasCertificate()) { char baseDomain[HOSTNAME_LENGTH]; AutoSSL_GetCertificateBaseDomain(baseDomain); char serverID[SERVER_NAME_LENGTH]; AutoSSL_GetCertificateServerID(serverID); printf("The certificate for %s.%s will expire in %d days.\n", serverID, baseDomain, AutoSSL_DaysUntilCertificateExpires()); if (askQuestion("Would you like to renew this certificate [y/n]")) { // Get the user's information from the current certificate BasicCustomerInfo * bci = malloc(sizeof (BasicCustomerInfo)); rc = AutoSSL_GetBasicCustomerInfo(bci); if(rc) { // call renewal rc = AutoSSL_RenewSSLCertificate(getAuthorization(), bci, 1); } free (bci); } } else { initializeAutoSSLParameters(); char reservationID[100]; // Try to reserve the user's serverID choice rc = AutoSSL_ReserveServerID(reservationID, BASE_DOMAIN, getServerID(), "RandomPassword"); if (rc) { BasicCustomerInfo * bci = malloc(sizeof (BasicCustomerInfo)); rc = AutoSSL_CreateBasicCustomerInfo(bci, getCustomerName(), getCity(), getState(), getCountry(), getEmail()); if(rc) { rc = AutoSSL_ProvisionSSLCertificate(reservationID, getAuthorization(), bci, 1); } free (bci); } } // This function should be called periodically by the application to ensure // that the DNS resolution stays current AutoSSL_UpdateDNSName(); // Clean up everythin we've done AutoSSL_ApplicationFinished(); } return 0; }