Certificate error handling in firefox

Certificate errors are error thrown on certain Websites.These errors tell us to accept new certificates for those websites and sometimes they tell us not to continue onto those websites as it may be unsafe. We can accept these certificates manually and continue to these websites, but question is how do we do this with selenium. If errors are thrown by Firefox we can fix it by creating a specific profile for Firefox which accepts those errors

FirefoxProfile prof = new FirefoxProfile();
prof.setAcceptUntrustedCertificates(true);
prof.setAssumeUntrustedCertificateIssuer(true);
WebDriver driver = new FirefoxDriver(prof);