+ Start a Discussion
FastSnailFastSnail 

public site/guest user access denied to static resource in Prodcution (SSL issue). OK in Sandbox

Hello everyone;
I have the following code running fine in Sandbox for all users, and in Production fo all users BUT for public site/guest user.
CCNUSADMIN_CurrencyRates cache is set to Public.
------------
PageReference curRatPR = new PageReference('/resource/CCNUSADMIN_CurrencyRates');
curRatList = curRatPR.getContent().toString().split(',', 0); 
---------
When accessed by the guest user, the following error, on the getContent() line:
avax.net.ssl.SSLPeerUnverifiedException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
---------
My Site SFDC URL is: http://ccnus.force.com/  which is redirected to a custom URL 'us.classiccarnetwork.org', served by a SSL certificate that runs OK. Any idea why I get this message and more important, what I need to do to allow the Public Site user to access this static resources?
Thanks in advance for your help. Best regards,
Jerome
SandhyaSandhya (Salesforce Developers) 
Hi,
In static resource edit check if Cache Control property is public.

Refer below links

https://developer.salesforce.com/page/Delivering_Static_Resources_with_Visualforce

https://salesforce.stackexchange.com/questions/78025/can-a-static-resource-be-accessed-from-site

https://developer.salesforce.com/forums/?id=906F000000097UjIAI

Please mark it as solved if my reply was helpful. It will make it available for other as the proper solution.
                                             
Best Regards
Sandhya
 
FastSnailFastSnail
Good mornng Sandhya,
Thanks for the quick reply. I had already read these links and it is not the answer to the problem. The static resoruce is Public.
My Production site is able to access other static resoruces (css, js) without problem through <apex:stylesheet value="{!URLFOR($Resource.CNGatAuw_css)}"/>
This staic resource is accessed throgh: PageReference('/resource/CCNUSADMIN_CurrencyRates'); which looks what is the problem, altough the apex return error is on the  'getConten()t'.
It looks that the problem is SSL related, I believe linked to the fact that my site uses a custom URL; Could that make sense?
Thanks again or your help. Could you forward this to technical support if you do not have any idea about how solving the problem? Thanks, Jerome
D McGovernD McGovern
Old thread, but did you ever get a solution figured out here?
FastSnailFastSnail
No, and yes.I could not get Site to access a public resource on SFDC in Production, so I externalized the file on a non-SFDC server as below:
https://ccnus.org/stares/CCNUSADMIN_CurrencyRates.xls
The apex code:
///PageReference curRatPR = new PageReference('/resource/CCNUSADMIN_CurrencyRates');  ///DOES NOT WORK FOR CCNUSSITE PR. OK SB
PageReference curRatPR = new PageReference('https://www.ccnus.org/stares/CCNUSADMIN_CurrencyRates.xls' (https://www.ccnus.org/stares/CCNUSADMIN_CurrencyRates.xls'));  ///WORKS SB/PR
////CNOrdMet() finds curRatPRS=USDAED3.673,USDARS9.298401,USDAUD1.420914,USDBHD0.3771
List<String> curRatList = new List<String>();
if(!test.isRunningTest()){
curRatList = curRatPR.getContent().toString().split(',', 0);  ///curRatList=(USDAED3.673, USDARS9.298401, USDAUD1.420914,
} else {                 ///Because test methods do not support getContent()
curRatList.add('USDUSD1.000');
curRatList.add('USDEUR1.200');
///finds curRatList=(USDUSD1.000, USDEUR1.200)
}
I hope this helops,
Jerome