How can I add a cipher_suite to the Erlang default ones? - ssl
I'm currently trying to add the cipher TLS_PSK_WITH_AES_128_CBC_SHA_256 to my default cipher_suite in Erlang 24 (on a CentOS 8 machine). Unfortunately, I'm not sure how to do so.
I know that the cipher is their cause:
1> ssl:str_to_suite("TLS_PSK_WITH_AES_128_CBC_SHA_256").
returns:
#{cipher => aes_128_cbc,key_exchange => psk,mac => sha256,
prf => sha256}
I do also know that the cipher is not activate cause
rp(ssl:cipher_suites(default,'tlsv1.2')).
does not list it:
[#{cipher => aes_256_gcm,key_exchange => ecdhe_ecdsa,
mac => aead,prf => sha384},
#{cipher => aes_256_gcm,key_exchange => ecdhe_rsa,mac => aead,
prf => sha384},
#{cipher => aes_256_ccm,key_exchange => ecdhe_ecdsa,
mac => aead,prf => default_prf},
#{cipher => aes_256_ccm_8,key_exchange => ecdhe_ecdsa,
mac => aead,prf => default_prf},
#{cipher => aes_256_cbc,key_exchange => ecdhe_ecdsa,
mac => sha384,prf => sha384},
#{cipher => aes_256_cbc,key_exchange => ecdhe_rsa,
mac => sha384,prf => sha384},
#{cipher => chacha20_poly1305,key_exchange => ecdhe_ecdsa,
mac => aead,prf => sha256},
#{cipher => chacha20_poly1305,key_exchange => ecdhe_rsa,
mac => aead,prf => sha256},
#{cipher => aes_128_gcm,key_exchange => ecdhe_ecdsa,
mac => aead,prf => sha256},
#{cipher => aes_128_gcm,key_exchange => ecdhe_rsa,mac => aead,
prf => sha256},
#{cipher => aes_128_ccm,key_exchange => ecdhe_ecdsa,
mac => aead,prf => default_prf},
#{cipher => aes_128_ccm_8,key_exchange => ecdhe_ecdsa,
mac => aead,prf => default_prf},
#{cipher => aes_256_gcm,key_exchange => ecdh_ecdsa,
mac => aead,prf => sha384},
#{cipher => aes_256_gcm,key_exchange => ecdh_rsa,mac => aead,
prf => sha384},
#{cipher => aes_256_cbc,key_exchange => ecdh_ecdsa,
mac => sha384,prf => sha384},
#{cipher => aes_256_cbc,key_exchange => ecdh_rsa,
mac => sha384,prf => sha384},
#{cipher => aes_128_gcm,key_exchange => ecdh_ecdsa,
mac => aead,prf => sha256},
#{cipher => aes_128_gcm,key_exchange => ecdh_rsa,mac => aead,
prf => sha256},
#{cipher => aes_128_cbc,key_exchange => ecdhe_ecdsa,
mac => sha256,prf => sha256},
#{cipher => aes_128_cbc,key_exchange => ecdhe_rsa,
mac => sha256,prf => sha256},
#{cipher => aes_128_cbc,key_exchange => ecdh_ecdsa,
mac => sha256,prf => sha256},
#{cipher => aes_128_cbc,key_exchange => ecdh_rsa,
mac => sha256,prf => sha256},
#{cipher => aes_256_gcm,key_exchange => dhe_rsa,mac => aead,
prf => sha384},
#{cipher => aes_256_gcm,key_exchange => dhe_dss,mac => aead,
prf => sha384},
#{cipher => aes_256_cbc,key_exchange => dhe_rsa,mac => sha256,
prf => default_prf},
#{cipher => aes_256_cbc,key_exchange => dhe_dss,mac => sha256,
prf => default_prf},
#{cipher => aes_128_gcm,key_exchange => dhe_rsa,mac => aead,
prf => sha256},
#{cipher => aes_128_gcm,key_exchange => dhe_dss,mac => aead,
prf => sha256},
#{cipher => chacha20_poly1305,key_exchange => dhe_rsa,
mac => aead,prf => sha256},
#{cipher => aes_128_cbc,key_exchange => dhe_rsa,mac => sha256,
prf => default_prf},
#{cipher => aes_128_cbc,key_exchange => dhe_dss,mac => sha256,
prf => default_prf},
#{cipher => aes_256_cbc,key_exchange => ecdhe_ecdsa,
mac => sha,prf => default_prf},
#{cipher => aes_256_cbc,key_exchange => ecdhe_rsa,mac => sha,
prf => default_prf},
#{cipher => aes_256_cbc,key_exchange => ecdh_ecdsa,mac => sha,
prf => default_prf},
#{cipher => aes_256_cbc,key_exchange => ecdh_rsa,mac => sha,
prf => default_prf},
#{cipher => aes_128_cbc,key_exchange => ecdhe_ecdsa,
mac => sha,prf => default_prf},
#{cipher => aes_128_cbc,key_exchange => ecdhe_rsa,mac => sha,
prf => default_prf},
#{cipher => aes_128_cbc,key_exchange => ecdh_ecdsa,mac => sha,
prf => default_prf},
#{cipher => aes_128_cbc,key_exchange => ecdh_rsa,mac => sha,
prf => default_prf},
#{cipher => aes_256_cbc,key_exchange => dhe_rsa,mac => sha,
prf => default_prf},
#{cipher => aes_256_cbc,key_exchange => dhe_dss,mac => sha,
prf => default_prf},
#{cipher => aes_128_cbc,key_exchange => dhe_rsa,mac => sha,
prf => default_prf},
#{cipher => aes_128_cbc,key_exchange => dhe_dss,mac => sha,
prf => default_prf}]
I need this cipher cause I want to connect to RabbitMQ (with the MQTT Plugin) for a device.
Does anyone know how to activate/enable a cipher in Erlang ?
Related
TypeError: undefined is not an object (evaluating 'items.filter') in react native
Why I am getting that error TypeError: undefined is not an object (evaluating 'items.filter') when using react-native-dropdown-autocomplete in my react native app? I am getting data from fetch method and store that data in arrayholder My code is like that <Autocomplete style={styles.input} scrollToInput={ev => {}} keyExtractor={(item, index) => index + ""} handleSelectItem={(item, id) => this.handleSelectItem(item, id)} onDropdownClose={() => onDropdownClose()} onDropdownShow={() => onDropdownShow()} onChangeText={(text) => this.searchFilterFunction(text)} data={this.state.data} minimumCharactersCount={0} highlightText valueExtractor={item => item.name} rightContent /> searchFilterFunction = (text) => { this.setState({ value: text, }); const newData = this.arrayholder.filter(item => { const itemData = `${item.name.toUpperCase()}`; const textData = text.toUpperCase(); return itemData.indexOf(textData) > -1; }); this.setState({ data: newData }); };
React Native API call
How do I display results from the API call in code lower in the page? The {data.payrollid} after Complete is not showing any value. ie: the text only shows 'Complete' with no value after it. My returned JSON looks like this... {"status_code":200,"payrollid":10,"message":"Success"} When I console.log(data) I can see that the fetch worked and I can see my JSON array. Below is my React Native code const [isLoading, setLoading] = useState(true); const [data, setData] = useState([]); useEffect(() => { fetch('https://www.mywebsite.ca/api/test.php') .then((response) => response.json()) .then((data) => console.log(data)) .catch((error) => console.error(error)) .finally(() => setLoading(false)); }, []); return ( <> <View> {isLoading ? <Text>Loading...</Text> : <Text>Complete {data.payrollid}</Text> } </View> <View style={styles.container}> <Text>This is my new app.</Text> <Text>Some text</Text> <StatusBar style="auto" /> </View> </> );
Your code should look something like this: const [isLoading, setLoading] = useState(true); const [data, setData] = useState({}); useEffect(() => { fetch('https://www.mywebsite.ca/api/test.php') .then((response) => response.json()) .then((data) => setData(data)) .catch((error) => console.error(error)) .finally(() => setLoading(false)); }, []); return ( <> <View> {isLoading ? <Text>Loading...</Text> : <Text>Complete{data.payrollid}.</Text> } </View> <View style={styles.container}> <Text>This is my new app.</Text> <Text>Your Text</Text> <StatusBar style="auto" /> </View> </> );
You need to save your data in your data state. const [data, setData] = useState({}); useEffect(() => { fetch('https://www.mywebsite.ca/api/test.php') .then((response) => response.json()) .then((data) => setData(data)) .catch((error) => console.error(error)) .finally(() => setLoading(false)); }, []); And since your getting an object switch your original state to an object.
Trying to get result from more than one api React native in the same page
i m trying to get data from database and put it inside a picker when i use one fecth it work fine but when i add the second one it get an error says " typeError: undefined is not an object (evaluating 'this.state.dataSource2.map') " componentDidMount() { fetch('url1') .then((response) => response.json()) .then((responseJson) => { this.setState({ isLoading: false, dataSource: responseJson, } ); }) .then( () => { fetch('url2') .then((response) => response.json()) .then((responseJson) => { this.setState({ isLoading: false, dataSource2: responseJson }); }) }) .catch((error) => { console.error(error); }); } first picker : onValueChange={(itemValue, itemIndex) => this.setState({ar1: itemValue})} > { this.state.dataSource.map((item, key)=>( <Picker.Item label={item.nom} value={item.nom} key={key} />) )} </Picker> second picker : onValueChange={(itemValue, itemIndex) => this.setState({ar2: itemValue})} > { this.state.dataSource2.map((item, key)=>( <Picker.Item label={item.nom} value={item.nom} key={key} />) )} </Picker>
Refresh data in react-native
Hi so I want to refresh data when I pull down but I'm not sure about how to do it. Here is my code : async componentDidMount() { this.getData(); } async getData(){ const url = "SomeUrl"; await fetch(url) .then(res => res.json()) .then(res => { this.setState({ dataSource: res }); }) .catch(error => { console.log("get data error:" + error); }); } <SafeAreaView style={{ flex:1 }}> <View style={styles.main_container}> <FlatList style={styles.flatList} data={this.state.dataSource} extraData = {this.state} keyExtractor={(item, index) => item.MembreId} renderItem={(item) => <UserItem user={item} displayDetailForUser={this._displayDetailForUser} />} numColumns={numColumns} refreshing={this.state.refreshing} onRefresh={this.handleRefresh} /> </View> </SafeAreaView> So here I'm getting the data in dataSource. I have tried this but it's loading endlessly.. And do I also need to wipe the previous data in dataSource first or not ? handleRefresh = () => { this.setState ( { refreshing: true, }, () => { setTimeout(() => {this.getData()}, 1000) } ); };
It looks like you are not setting the refreshing back to false once the data comes back. Try this for getData: async getData(){ const url = "SomeUrl"; await fetch(url) .then(res => res.json()) .then(res => { this.setState({ dataSource: res, refreshing: false, }); }) .catch(error => { console.log("get data error:" + error); }); }
Try setting refreshing state to false in this.getData() with dataSource.
Prestashop Remove id categories
I am Prestashop user im trying to find a url category solution I need to know the process to remove the category id (Numeric) for Prestashop url. For Example www.mydomain.com/16-myproducts Regards
Actually you might do an Override of Dispatcher.php class. It pretty much depends on which version you are. Here is how we did this at Malttt on 1.6, last year, please take care with this code, as it may be outdated, it also covers other cases (products, suppliers ...) : /* * #author Matt Loye <matthieu#agence-malttt.fr> * #copyright 2016-2017 Agence Malttt */ class Dispatcher extends DispatcherCore { /** * #var array List of default routes */ public $default_routes = array( 'supplier_rule' => array( 'controller' => 'supplier', 'rule' => 'supplier/{rewrite}/', 'keywords' => array( 'id' => array('regexp' => '[0-9]+'), 'rewrite' => array('regexp' => '[_a-zA-Z0-9-\pL]*', 'param' => 'supplier_rewrite'), 'meta_keywords' => array('regexp' => '[_a-zA-Z0-9-\pL]*'), 'meta_title' => array('regexp' => '[_a-zA-Z0-9-\pL]*'), ), ), 'manufacturer_rule' => array( 'controller' => 'manufacturer', 'rule' => 'manufacturer/{rewrite}/', 'keywords' => array( 'id' => array('regexp' => '[0-9]+'), 'rewrite' => array('regexp' => '[_a-zA-Z0-9-\pL]*', 'param' => 'manufacturer_rewrite'), 'meta_keywords' => array('regexp' => '[_a-zA-Z0-9-\pL]*'), 'meta_title' => array('regexp' => '[_a-zA-Z0-9-\pL]*'), ), ), 'cms_rule' => array( 'controller' => 'cms', 'rule' => 'info/{rewrite}', 'keywords' => array( 'id' => array('regexp' => '[0-9]+'), 'rewrite' => array('regexp' => '[_a-zA-Z0-9-\pL]*', 'param' => 'cms_rewrite'), 'meta_keywords' => array('regexp' => '[_a-zA-Z0-9-\pL]*'), 'meta_title' => array('regexp' => '[_a-zA-Z0-9-\pL]*'), ), ), 'cms_category_rule' => array( 'controller' => 'cms', 'rule' => 'info/{rewrite}/', 'keywords' => array( 'id' => array('regexp' => '[0-9]+'), 'rewrite' => array('regexp' => '[_a-zA-Z0-9-\pL]*', 'param' => 'cms_category_rewrite'), 'meta_keywords' => array('regexp' => '[_a-zA-Z0-9-\pL]*'), 'meta_title' => array('regexp' => '[_a-zA-Z0-9-\pL]*'), ), ), 'module' => array( 'controller' => null, 'rule' => 'module/{module}{/:controller}', 'keywords' => array( 'module' => array('regexp' => '[_a-zA-Z0-9_-]+', 'param' => 'module'), 'controller' => array('regexp' => '[_a-zA-Z0-9_-]+', 'param' => 'controller'), ), 'params' => array( 'fc' => 'module', ), ), 'product_rule' => array( 'controller' => 'product', 'rule' => '{category:/}{rewrite}.html', 'keywords' => array( 'id' => array('regexp' => '[0-9]+'), 'rewrite' => array('regexp' => '[_a-zA-Z0-9-\pL]*', 'param' => 'product_rewrite'), 'ean13' => array('regexp' => '[0-9\pL]*'), 'category' => array('regexp' => '[_a-zA-Z0-9-\pL]*'), 'categories' => array('regexp' => '[/_a-zA-Z0-9-\pL]*'), 'reference' => array('regexp' => '[_a-zA-Z0-9-\pL]*'), 'meta_keywords' => array('regexp' => '[_a-zA-Z0-9-\pL]*'), 'meta_title' => array('regexp' => '[_a-zA-Z0-9-\pL]*'), 'manufacturer' => array('regexp' => '[_a-zA-Z0-9-\pL]*'), 'supplier' => array('regexp' => '[_a-zA-Z0-9-\pL]*'), 'price' => array('regexp' => '[0-9\.,]*'), 'tags' => array('regexp' => '[a-zA-Z0-9-\pL]*'), ), ), 'layered_rule' => array( 'controller' => 'category', 'rule' => '{rewrite}/filter{selected_filters}', 'keywords' => array( 'id' => array('regexp' => '[0-9]+'), /* Selected filters is used by the module blocklayered */ 'selected_filters' => array('regexp' => '.*', 'param' => 'selected_filters'), 'rewrite' => array('regexp' => '[_a-zA-Z0-9-\pL]*', 'param' => 'category_rewrite'), 'meta_keywords' => array('regexp' => '[_a-zA-Z0-9-\pL]*'), 'meta_title' => array('regexp' => '[_a-zA-Z0-9-\pL]*'), ), ), 'category_rule' => array( 'controller' => 'category', 'rule' => '{rewrite}/', 'keywords' => array( 'id' => array('regexp' => '[0-9]+'), 'categories' => array('regexp' => '[/_a-zA-Z0-9-\pL]*'), 'rewrite' => array('regexp' => '[_a-zA-Z0-9-\pL]*', 'param' => 'category_rewrite'), 'meta_keywords' => array('regexp' => '[_a-zA-Z0-9-\pL]*'), 'meta_title' => array('regexp' => '[_a-zA-Z0-9-\pL]*'), ), ), ); }